mirror of https://github.com/rwf2/Rocket.git
Make TLS misconfig an error. Always print launch message.
This commit is contained in:
parent
1516ca4fb6
commit
6f29696b4f
|
@ -4,7 +4,7 @@ version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../../"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rocket = { path = "../../lib", features = ["tls"] }
|
rocket = { path = "../../lib" }
|
||||||
rocket_codegen = { path = "../../codegen" }
|
rocket_codegen = { path = "../../codegen" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
|
@ -66,6 +66,13 @@ macro_rules! log_ {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)] #[macro_export]
|
||||||
|
macro_rules! launch_info {
|
||||||
|
($format:expr, $($args:expr),*) => {
|
||||||
|
error!(target: "launch", $format, $($args),*)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[doc(hidden)] #[macro_export]
|
#[doc(hidden)] #[macro_export]
|
||||||
macro_rules! error_ { ($($args:expr),+) => { log_!(error: $($args),+); }; }
|
macro_rules! error_ { ($($args:expr),+) => { log_!(error: $($args),+); }; }
|
||||||
#[doc(hidden)] #[macro_export]
|
#[doc(hidden)] #[macro_export]
|
||||||
|
@ -78,6 +85,7 @@ macro_rules! debug_ { ($($args:expr),+) => { log_!(debug: $($args),+); }; }
|
||||||
macro_rules! warn_ { ($($args:expr),+) => { log_!(warn: $($args),+); }; }
|
macro_rules! warn_ { ($($args:expr),+) => { log_!(warn: $($args),+); }; }
|
||||||
|
|
||||||
impl Log for RocketLogger {
|
impl Log for RocketLogger {
|
||||||
|
#[inline(always)]
|
||||||
fn enabled(&self, md: &LogMetadata) -> bool {
|
fn enabled(&self, md: &LogMetadata) -> bool {
|
||||||
md.level() <= self.0.max_log_level()
|
md.level() <= self.0.max_log_level()
|
||||||
}
|
}
|
||||||
|
@ -88,6 +96,14 @@ impl Log for RocketLogger {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We use the `launch_info` macro to "fake" a high priority info
|
||||||
|
// message. We want to print the message unless the user uses a custom
|
||||||
|
// drain, so we set it's status to critical, but reset it here to info.
|
||||||
|
let level = match record.target() {
|
||||||
|
"launch" => Info,
|
||||||
|
_ => record.level()
|
||||||
|
};
|
||||||
|
|
||||||
// Don't print Hyper or Rustls messages unless debug is enabled.
|
// Don't print Hyper or Rustls messages unless debug is enabled.
|
||||||
let from_hyper = record.location().module_path().starts_with("hyper::");
|
let from_hyper = record.location().module_path().starts_with("hyper::");
|
||||||
let from_rustls = record.location().module_path().starts_with("rustls::");
|
let from_rustls = record.location().module_path().starts_with("rustls::");
|
||||||
|
@ -101,7 +117,7 @@ impl Log for RocketLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
use log::LogLevel::*;
|
use log::LogLevel::*;
|
||||||
match record.level() {
|
match level {
|
||||||
Info => println!("{}", Blue.paint(record.args())),
|
Info => println!("{}", Blue.paint(record.args())),
|
||||||
Trace => println!("{}", Magenta.paint(record.args())),
|
Trace => println!("{}", Magenta.paint(record.args())),
|
||||||
Error => {
|
Error => {
|
||||||
|
|
|
@ -387,9 +387,9 @@ impl Rocket {
|
||||||
if tls_configured && cfg!(feature = "tls") {
|
if tls_configured && cfg!(feature = "tls") {
|
||||||
info_!("tls: {}", White.paint("enabled"));
|
info_!("tls: {}", White.paint("enabled"));
|
||||||
} else {
|
} else {
|
||||||
info_!("tls: {}", White.paint("disabled"));
|
error_!("tls: {}", White.paint("disabled"));
|
||||||
if tls_configured {
|
if tls_configured {
|
||||||
warn_!("tls is configured, but the tls feature is disabled");
|
error_!("tls is configured, but the tls feature is disabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,7 +602,7 @@ impl Rocket {
|
||||||
Err(e) => return LaunchError::from(e)
|
Err(e) => return LaunchError::from(e)
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("🚀 {} {}{}",
|
launch_info!("🚀 {} {}{}",
|
||||||
White.paint("Rocket has launched from"),
|
White.paint("Rocket has launched from"),
|
||||||
White.bold().paint(proto),
|
White.bold().paint(proto),
|
||||||
White.bold().paint(&full_addr));
|
White.bold().paint(&full_addr));
|
||||||
|
|
Loading…
Reference in New Issue