mirror of https://github.com/rwf2/Rocket.git
Always log launch message.
Users experience confusion when the server appears to do "nothing" when compiled in release mode. In reality, the server has started, but it offers no indication in that direction via log message. Often users misconfigure the port or address, but that information isn't displayed. This commit makes it such that only the final "Rocket has launched!" log message is displayed, which includes the listening address, port, and protocol.
This commit is contained in:
parent
c08c39e16f
commit
885cdfd61c
|
@ -357,52 +357,52 @@ impl Config {
|
|||
Paint::default(val).bold()
|
||||
}
|
||||
|
||||
launch_info!("{}Configured for {}.", Paint::emoji("🔧 "), self.profile);
|
||||
launch_info_!("address: {}", bold(&self.address));
|
||||
launch_info_!("port: {}", bold(&self.port));
|
||||
launch_info_!("workers: {}", bold(self.workers));
|
||||
launch_info_!("max blocking threads: {}", bold(self.max_blocking));
|
||||
launch_info_!("ident: {}", bold(&self.ident));
|
||||
launch_info_!("limits: {}", bold(&self.limits));
|
||||
launch_info_!("temp dir: {}", bold(&self.temp_dir.relative().display()));
|
||||
launch_info_!("http/2: {}", bold(cfg!(feature = "http2")));
|
||||
launch_meta!("{}Configured for {}.", Paint::emoji("🔧 "), self.profile);
|
||||
launch_meta_!("address: {}", bold(&self.address));
|
||||
launch_meta_!("port: {}", bold(&self.port));
|
||||
launch_meta_!("workers: {}", bold(self.workers));
|
||||
launch_meta_!("max blocking threads: {}", bold(self.max_blocking));
|
||||
launch_meta_!("ident: {}", bold(&self.ident));
|
||||
launch_meta_!("limits: {}", bold(&self.limits));
|
||||
launch_meta_!("temp dir: {}", bold(&self.temp_dir.relative().display()));
|
||||
launch_meta_!("http/2: {}", bold(cfg!(feature = "http2")));
|
||||
|
||||
match self.keep_alive {
|
||||
0 => launch_info_!("keep-alive: {}", bold("disabled")),
|
||||
ka => launch_info_!("keep-alive: {}{}", bold(ka), bold("s")),
|
||||
0 => launch_meta_!("keep-alive: {}", bold("disabled")),
|
||||
ka => launch_meta_!("keep-alive: {}{}", bold(ka), bold("s")),
|
||||
}
|
||||
|
||||
match (self.tls_enabled(), self.mtls_enabled()) {
|
||||
(true, true) => launch_info_!("tls: {}", bold("enabled w/mtls")),
|
||||
(true, false) => launch_info_!("tls: {} w/o mtls", bold("enabled")),
|
||||
(false, _) => launch_info_!("tls: {}", bold("disabled")),
|
||||
(true, true) => launch_meta_!("tls: {}", bold("enabled w/mtls")),
|
||||
(true, false) => launch_meta_!("tls: {} w/o mtls", bold("enabled")),
|
||||
(false, _) => launch_meta_!("tls: {}", bold("disabled")),
|
||||
}
|
||||
|
||||
#[cfg(feature = "secrets")] {
|
||||
launch_info_!("secret key: {}", bold(&self.secret_key));
|
||||
launch_meta_!("secret key: {}", bold(&self.secret_key));
|
||||
if !self.secret_key.is_provided() {
|
||||
warn!("secrets enabled without a stable `secret_key`");
|
||||
launch_info_!("disable `secrets` feature or configure a `secret_key`");
|
||||
launch_info_!("this becomes an {} in non-debug profiles", Paint::red("error"));
|
||||
launch_meta_!("disable `secrets` feature or configure a `secret_key`");
|
||||
launch_meta_!("this becomes an {} in non-debug profiles", Paint::red("error"));
|
||||
}
|
||||
}
|
||||
|
||||
launch_info_!("shutdown: {}", bold(&self.shutdown));
|
||||
launch_info_!("log level: {}", bold(self.log_level));
|
||||
launch_info_!("cli colors: {}", bold(&self.cli_colors));
|
||||
launch_meta_!("shutdown: {}", bold(&self.shutdown));
|
||||
launch_meta_!("log level: {}", bold(self.log_level));
|
||||
launch_meta_!("cli colors: {}", bold(&self.cli_colors));
|
||||
|
||||
// Check for now depreacted config values.
|
||||
for (key, replacement) in Self::DEPRECATED_KEYS {
|
||||
if let Some(md) = figment.find_metadata(key) {
|
||||
warn!("found value for deprecated config key `{}`", Paint::white(key));
|
||||
if let Some(ref source) = md.source {
|
||||
launch_info_!("in {} {}", Paint::white(source), md.name);
|
||||
launch_meta_!("in {} {}", Paint::white(source), md.name);
|
||||
}
|
||||
|
||||
if let Some(new_key) = replacement {
|
||||
launch_info_!("key has been by replaced by `{}`", Paint::white(new_key));
|
||||
launch_meta_!("key has been by replaced by `{}`", Paint::white(new_key));
|
||||
} else {
|
||||
launch_info_!("key has no special meaning");
|
||||
launch_meta_!("key has no special meaning");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -413,9 +413,9 @@ impl Config {
|
|||
warn!("found set deprecated profile `{}`", Paint::white(profile));
|
||||
|
||||
if let Some(new_profile) = replacement {
|
||||
launch_info_!("profile was replaced by `{}`", Paint::white(new_profile));
|
||||
launch_meta_!("profile was replaced by `{}`", Paint::white(new_profile));
|
||||
} else {
|
||||
launch_info_!("profile `{}` has no special meaning", profile);
|
||||
launch_meta_!("profile `{}` has no special meaning", profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,10 +173,10 @@ impl Fairings {
|
|||
pub fn pretty_print(&self) {
|
||||
let active_fairings = self.active().collect::<HashSet<_>>();
|
||||
if !active_fairings.is_empty() {
|
||||
launch_info!("{}{}:", Paint::emoji("📡 "), Paint::magenta("Fairings"));
|
||||
launch_meta!("{}{}:", Paint::emoji("📡 "), Paint::magenta("Fairings"));
|
||||
|
||||
for (_, fairing) in iter!(self, active_fairings.into_iter()) {
|
||||
launch_info_!("{} ({})", Paint::default(fairing.info().name).bold(),
|
||||
launch_meta_!("{} ({})", Paint::default(fairing.info().name).bold(),
|
||||
Paint::blue(fairing.info().kind).bold());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,12 +19,16 @@ macro_rules! define_log_macro {
|
|||
($d ($t:tt)*) => ($crate::log::private::$kind!(target: $target, $d ($t)*))
|
||||
}
|
||||
);
|
||||
($name:ident ($indented:ident): $kind:ident, $target:expr, $d:tt) => (
|
||||
define_log_macro!($name: $kind, $target, $d);
|
||||
define_log_macro!($indented: $kind, $target, $d);
|
||||
);
|
||||
($kind:ident, $indented:ident) => (
|
||||
define_log_macro!($kind: $kind, module_path!(), $);
|
||||
define_log_macro!($indented: $kind, "_", $);
|
||||
|
||||
pub use $indented;
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
define_log_macro!(error, error_);
|
||||
|
@ -32,8 +36,8 @@ define_log_macro!(warn, warn_);
|
|||
define_log_macro!(info, info_);
|
||||
define_log_macro!(debug, debug_);
|
||||
define_log_macro!(trace, trace_);
|
||||
define_log_macro!(launch_info: info, "rocket::launch", $);
|
||||
define_log_macro!(launch_info_: info, "rocket::launch_", $);
|
||||
define_log_macro!(launch_meta (launch_meta_): info, "rocket::launch", $);
|
||||
define_log_macro!(launch_info (launch_msg_): warn, "rocket::launch", $);
|
||||
|
||||
// `print!` panics when stdout isn't available, but this macro doesn't. See
|
||||
// SergioBenitez/Rocket#2019 and rust-lang/rust#46016 for more.
|
||||
|
@ -80,7 +84,7 @@ pub trait PaintExt {
|
|||
fn emoji(item: &str) -> Paint<&str>;
|
||||
}
|
||||
|
||||
// Whether a record is a special `launch_info!` record.
|
||||
// Whether a record is a special `launch_{meta,info}!` record.
|
||||
fn is_launch_record(record: &log::Metadata<'_>) -> bool {
|
||||
record.target().contains("rocket::launch")
|
||||
}
|
||||
|
|
|
@ -571,14 +571,14 @@ fn log_items<T, I, B, O>(e: &str, t: &str, items: I, base: B, origin: O)
|
|||
{
|
||||
let mut items: Vec<_> = items.collect();
|
||||
if !items.is_empty() {
|
||||
launch_info!("{}{}:", Paint::emoji(e), Paint::magenta(t));
|
||||
launch_meta!("{}{}:", Paint::emoji(e), Paint::magenta(t));
|
||||
}
|
||||
|
||||
items.sort_by_key(|i| origin(i).path().as_str().chars().count());
|
||||
items.sort_by_key(|i| origin(i).path().segments().len());
|
||||
items.sort_by_key(|i| base(i).path().as_str().chars().count());
|
||||
items.sort_by_key(|i| base(i).path().segments().len());
|
||||
items.iter().for_each(|i| launch_info_!("{}", i));
|
||||
items.iter().for_each(|i| launch_meta_!("{}", i));
|
||||
}
|
||||
|
||||
impl Rocket<Ignite> {
|
||||
|
|
Loading…
Reference in New Issue