mirror of https://github.com/rwf2/Rocket.git
Stop using white for legible logging everywhere.
Prior to this change, Rocket emitted "white" text in much of its logging output. On terminals with light backgrounds, the text was nearly illegible. This PR stops using white coloring altogether, opting instead to use the terminal's default color albeit with bold styling. On dark terminals, this will likely be a light color, and on light terminals, this will likely be a dark color. The end result is that Rocket's logging output should be readable everywhere. Resolves #639.
This commit is contained in:
parent
76c830a467
commit
abb434f228
|
@ -22,5 +22,5 @@ devise = "0.1"
|
||||||
quote = "0.6"
|
quote = "0.6"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
yansi = "0.4"
|
yansi = { git = "https://github.com/SergioBenitez/yansi", rev = "59c3a91" }
|
||||||
version_check = "0.1.3"
|
version_check = "0.1.3"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
extern crate yansi;
|
extern crate yansi;
|
||||||
extern crate version_check;
|
extern crate version_check;
|
||||||
|
|
||||||
use yansi::Color::{Red, Yellow, Blue, White};
|
use yansi::Color::{Red, Yellow, Blue};
|
||||||
use version_check::{supports_features, is_min_version, is_min_date};
|
use version_check::{supports_features, is_min_version, is_min_date};
|
||||||
|
|
||||||
// Specifies the minimum nightly version needed to compile Rocket.
|
// Specifies the minimum nightly version needed to compile Rocket.
|
||||||
|
@ -19,9 +19,9 @@ fn main() {
|
||||||
|
|
||||||
let print_version_err = |version: &str, date: &str| {
|
let print_version_err = |version: &str, date: &str| {
|
||||||
eprintln!("{} {}. {} {}.",
|
eprintln!("{} {}. {} {}.",
|
||||||
White.paint("Installed version is:"),
|
"Installed version is:",
|
||||||
Yellow.paint(format!("{} ({})", version, date)),
|
Yellow.paint(format!("{} ({})", version, date)),
|
||||||
White.paint("Minimum required:"),
|
"Minimum required:",
|
||||||
Yellow.paint(format!("{} ({})", MIN_VERSION, MIN_DATE)));
|
Yellow.paint(format!("{} ({})", MIN_VERSION, MIN_DATE)));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -29,11 +29,11 @@ fn main() {
|
||||||
if !ok_channel {
|
if !ok_channel {
|
||||||
eprintln!("{} {}",
|
eprintln!("{} {}",
|
||||||
Red.paint("Error:").bold(),
|
Red.paint("Error:").bold(),
|
||||||
White.paint("Rocket requires a nightly or dev version of Rust."));
|
"Rocket requires a nightly or dev version of Rust.");
|
||||||
print_version_err(&*version, &*date);
|
print_version_err(&*version, &*date);
|
||||||
eprintln!("{}{}{}",
|
eprintln!("{}{}{}",
|
||||||
Blue.paint("See the getting started guide ("),
|
Blue.paint("See the getting started guide ("),
|
||||||
White.paint("https://rocket.rs/v0.4/guide/getting-started/"),
|
"https://rocket.rs/v0.4/guide/getting-started/",
|
||||||
Blue.paint(") for more information."));
|
Blue.paint(") for more information."));
|
||||||
panic!("Aborting compilation due to incompatible compiler.")
|
panic!("Aborting compilation due to incompatible compiler.")
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,9 @@ fn main() {
|
||||||
if !ok_version || !ok_date {
|
if !ok_version || !ok_date {
|
||||||
eprintln!("{} {}",
|
eprintln!("{} {}",
|
||||||
Red.paint("Error:").bold(),
|
Red.paint("Error:").bold(),
|
||||||
White.paint("Rocket requires a more recent version of rustc."));
|
"Rocket requires a more recent version of rustc.");
|
||||||
eprintln!("{}{}{}",
|
eprintln!("{}{}{}",
|
||||||
Blue.paint("Use `"),
|
Blue.paint("Use `"), "rustup update",
|
||||||
White.paint("rustup update"),
|
|
||||||
Blue.paint("` or your preferred method to update Rust."));
|
Blue.paint("` or your preferred method to update Rust."));
|
||||||
print_version_err(&*version, &*date);
|
print_version_err(&*version, &*date);
|
||||||
panic!("Aborting compilation due to incompatible compiler.")
|
panic!("Aborting compilation due to incompatible compiler.")
|
||||||
|
|
|
@ -21,7 +21,7 @@ rocket_http = { version = "0.4.0-rc.1", path = "../http/" }
|
||||||
devise = "0.1"
|
devise = "0.1"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
yansi = "0.4"
|
yansi = { git = "https://github.com/SergioBenitez/yansi", rev = "59c3a91" }
|
||||||
version_check = "0.1.3"
|
version_check = "0.1.3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
extern crate yansi;
|
extern crate yansi;
|
||||||
extern crate version_check;
|
extern crate version_check;
|
||||||
|
|
||||||
use yansi::Color::{Red, Yellow, Blue, White};
|
use yansi::Color::{Red, Yellow, Blue};
|
||||||
use version_check::{supports_features, is_min_version, is_min_date};
|
use version_check::{supports_features, is_min_version, is_min_date};
|
||||||
|
|
||||||
// Specifies the minimum nightly version needed to compile Rocket.
|
// Specifies the minimum nightly version needed to compile Rocket.
|
||||||
|
@ -19,9 +19,9 @@ fn main() {
|
||||||
|
|
||||||
let print_version_err = |version: &str, date: &str| {
|
let print_version_err = |version: &str, date: &str| {
|
||||||
eprintln!("{} {}. {} {}.",
|
eprintln!("{} {}. {} {}.",
|
||||||
White.paint("Installed version is:"),
|
"Installed version is:",
|
||||||
Yellow.paint(format!("{} ({})", version, date)),
|
Yellow.paint(format!("{} ({})", version, date)),
|
||||||
White.paint("Minimum required:"),
|
"Minimum required:",
|
||||||
Yellow.paint(format!("{} ({})", MIN_VERSION, MIN_DATE)));
|
Yellow.paint(format!("{} ({})", MIN_VERSION, MIN_DATE)));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -29,11 +29,11 @@ fn main() {
|
||||||
if !ok_channel {
|
if !ok_channel {
|
||||||
eprintln!("{} {}",
|
eprintln!("{} {}",
|
||||||
Red.paint("Error:").bold(),
|
Red.paint("Error:").bold(),
|
||||||
White.paint("Rocket requires a nightly or dev version of Rust."));
|
"Rocket requires a nightly or dev version of Rust.");
|
||||||
print_version_err(&*version, &*date);
|
print_version_err(&*version, &*date);
|
||||||
eprintln!("{}{}{}",
|
eprintln!("{}{}{}",
|
||||||
Blue.paint("See the getting started guide ("),
|
Blue.paint("See the getting started guide ("),
|
||||||
White.paint("https://rocket.rs/v0.4/guide/getting-started/"),
|
"https://rocket.rs/v0.4/guide/getting-started/",
|
||||||
Blue.paint(") for more information."));
|
Blue.paint(") for more information."));
|
||||||
panic!("Aborting compilation due to incompatible compiler.")
|
panic!("Aborting compilation due to incompatible compiler.")
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,9 @@ fn main() {
|
||||||
if !ok_version || !ok_date {
|
if !ok_version || !ok_date {
|
||||||
eprintln!("{} {}",
|
eprintln!("{} {}",
|
||||||
Red.paint("Error:").bold(),
|
Red.paint("Error:").bold(),
|
||||||
White.paint("Rocket requires a more recent version of rustc."));
|
"Rocket requires a more recent version of rustc.");
|
||||||
eprintln!("{}{}{}",
|
eprintln!("{}{}{}",
|
||||||
Blue.paint("Use `"),
|
Blue.paint("Use `"), "rustup update",
|
||||||
White.paint("rustup update"),
|
|
||||||
Blue.paint("` or your preferred method to update Rust."));
|
Blue.paint("` or your preferred method to update Rust."));
|
||||||
print_version_err(&*version, &*date);
|
print_version_err(&*version, &*date);
|
||||||
panic!("Aborting compilation due to incompatible compiler.")
|
panic!("Aborting compilation due to incompatible compiler.")
|
||||||
|
|
|
@ -22,7 +22,7 @@ private-cookies = ["rocket_http/private-cookies"]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rocket_codegen = { version = "0.4.0-rc.1", path = "../codegen" }
|
rocket_codegen = { version = "0.4.0-rc.1", path = "../codegen" }
|
||||||
rocket_http = { version = "0.4.0-rc.1", path = "../http" }
|
rocket_http = { version = "0.4.0-rc.1", path = "../http" }
|
||||||
yansi = "0.4"
|
yansi = { git = "https://github.com/SergioBenitez/yansi", rev = "59c3a91" }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
toml = "0.4.7"
|
toml = "0.4.7"
|
||||||
num_cpus = "1.0"
|
num_cpus = "1.0"
|
||||||
|
@ -38,7 +38,7 @@ isatty = "0.1"
|
||||||
lazy_static = "1.0"
|
lazy_static = "1.0"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
yansi = "0.4"
|
yansi = { git = "https://github.com/SergioBenitez/yansi", rev = "59c3a91" }
|
||||||
version_check = "0.1.3"
|
version_check = "0.1.3"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
extern crate yansi;
|
extern crate yansi;
|
||||||
extern crate version_check;
|
extern crate version_check;
|
||||||
|
|
||||||
use yansi::Color::{Red, Yellow, Blue, White};
|
use yansi::Color::{Red, Yellow, Blue};
|
||||||
use version_check::{supports_features, is_min_version, is_min_date};
|
use version_check::{supports_features, is_min_version, is_min_date};
|
||||||
|
|
||||||
// Specifies the minimum nightly version needed to compile Rocket.
|
// Specifies the minimum nightly version needed to compile Rocket.
|
||||||
|
@ -19,9 +19,9 @@ fn main() {
|
||||||
|
|
||||||
let print_version_err = |version: &str, date: &str| {
|
let print_version_err = |version: &str, date: &str| {
|
||||||
eprintln!("{} {}. {} {}.",
|
eprintln!("{} {}. {} {}.",
|
||||||
White.paint("Installed version is:"),
|
"Installed version is:",
|
||||||
Yellow.paint(format!("{} ({})", version, date)),
|
Yellow.paint(format!("{} ({})", version, date)),
|
||||||
White.paint("Minimum required:"),
|
"Minimum required:",
|
||||||
Yellow.paint(format!("{} ({})", MIN_VERSION, MIN_DATE)));
|
Yellow.paint(format!("{} ({})", MIN_VERSION, MIN_DATE)));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -29,11 +29,11 @@ fn main() {
|
||||||
if !ok_channel {
|
if !ok_channel {
|
||||||
eprintln!("{} {}",
|
eprintln!("{} {}",
|
||||||
Red.paint("Error:").bold(),
|
Red.paint("Error:").bold(),
|
||||||
White.paint("Rocket requires a nightly or dev version of Rust."));
|
"Rocket requires a nightly or dev version of Rust.");
|
||||||
print_version_err(&*version, &*date);
|
print_version_err(&*version, &*date);
|
||||||
eprintln!("{}{}{}",
|
eprintln!("{}{}{}",
|
||||||
Blue.paint("See the getting started guide ("),
|
Blue.paint("See the getting started guide ("),
|
||||||
White.paint("https://rocket.rs/v0.4/guide/getting-started/"),
|
"https://rocket.rs/v0.4/guide/getting-started/",
|
||||||
Blue.paint(") for more information."));
|
Blue.paint(") for more information."));
|
||||||
panic!("Aborting compilation due to incompatible compiler.")
|
panic!("Aborting compilation due to incompatible compiler.")
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,9 @@ fn main() {
|
||||||
if !ok_version || !ok_date {
|
if !ok_version || !ok_date {
|
||||||
eprintln!("{} {}",
|
eprintln!("{} {}",
|
||||||
Red.paint("Error:").bold(),
|
Red.paint("Error:").bold(),
|
||||||
White.paint("Rocket requires a more recent version of rustc."));
|
"Rocket requires a more recent version of rustc.");
|
||||||
eprintln!("{}{}{}",
|
eprintln!("{}{}{}",
|
||||||
Blue.paint("Use `"),
|
Blue.paint("Use `"), "rustup update",
|
||||||
White.paint("rustup update"),
|
|
||||||
Blue.paint("` or your preferred method to update Rust."));
|
Blue.paint("` or your preferred method to update Rust."));
|
||||||
print_version_err(&*version, &*date);
|
print_version_err(&*version, &*date);
|
||||||
panic!("Aborting compilation due to incompatible compiler.")
|
panic!("Aborting compilation due to incompatible compiler.")
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
|
use std::{io, fmt};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::{io, fmt};
|
|
||||||
|
use yansi::Paint;
|
||||||
|
|
||||||
use super::Environment;
|
use super::Environment;
|
||||||
use self::ConfigError::*;
|
use self::ConfigError::*;
|
||||||
|
|
||||||
use yansi::Color::White;
|
|
||||||
|
|
||||||
/// The type of a configuration error.
|
/// The type of a configuration error.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ConfigError {
|
pub enum ConfigError {
|
||||||
|
@ -60,53 +60,53 @@ impl ConfigError {
|
||||||
NotFound => error!("config file was not found"),
|
NotFound => error!("config file was not found"),
|
||||||
IoError => error!("failed reading the config file: IO error"),
|
IoError => error!("failed reading the config file: IO error"),
|
||||||
Io(ref error, param) => {
|
Io(ref error, param) => {
|
||||||
error!("I/O error while setting {}:", White.paint(param));
|
error!("I/O error while setting {}:", Paint::default(param).bold());
|
||||||
info_!("{}", error);
|
info_!("{}", error);
|
||||||
}
|
}
|
||||||
BadFilePath(ref path, reason) => {
|
BadFilePath(ref path, reason) => {
|
||||||
error!("configuration file path '{:?}' is invalid", path);
|
error!("configuration file path {} is invalid", Paint::default(path.display()).bold());
|
||||||
info_!("{}", reason);
|
info_!("{}", reason);
|
||||||
}
|
}
|
||||||
BadEntry(ref name, ref filename) => {
|
BadEntry(ref name, ref filename) => {
|
||||||
let valid_entries = format!("{}, and global", valid_envs);
|
let valid_entries = format!("{}, global", valid_envs);
|
||||||
error!("[{}] is not a known configuration environment", name);
|
error!("{} is not a known configuration environment",
|
||||||
info_!("in {:?}", White.paint(filename));
|
Paint::default(format!("[{}]", name)).bold());
|
||||||
info_!("valid environments are: {}", White.paint(valid_entries));
|
info_!("in {}", Paint::default(filename.display()).bold());
|
||||||
|
info_!("valid environments are: {}", Paint::default(valid_entries).bold());
|
||||||
}
|
}
|
||||||
BadEnv(ref name) => {
|
BadEnv(ref name) => {
|
||||||
error!("'{}' is not a valid ROCKET_ENV value", name);
|
error!("{} is not a valid ROCKET_ENV value", Paint::default(name).bold());
|
||||||
info_!("valid environments are: {}", White.paint(valid_envs));
|
info_!("valid environments are: {}", Paint::default(valid_envs).bold());
|
||||||
}
|
}
|
||||||
BadType(ref name, expected, actual, ref filename) => {
|
BadType(ref name, expected, actual, ref filename) => {
|
||||||
error!("{} key could not be parsed", White.paint(name));
|
error!("{} key could not be parsed", Paint::default(name).bold());
|
||||||
if let Some(filename) = filename {
|
if let Some(filename) = filename {
|
||||||
info_!("in {:?}", White.paint(filename));
|
info_!("in {}", Paint::default(filename.display()).bold());
|
||||||
}
|
}
|
||||||
|
|
||||||
info_!("expected value to be {}, but found {}",
|
info_!("expected value to be {}, but found {}",
|
||||||
White.paint(expected), White.paint(actual));
|
Paint::default(expected).bold(), Paint::default(actual).bold());
|
||||||
}
|
}
|
||||||
ParseError(_, ref filename, ref desc, line_col) => {
|
ParseError(_, ref filename, ref desc, line_col) => {
|
||||||
error!("config file failed to parse due to invalid TOML");
|
error!("config file failed to parse due to invalid TOML");
|
||||||
info_!("{}", desc);
|
info_!("{}", desc);
|
||||||
|
info_!("in {}", Paint::default(filename.display()).bold());
|
||||||
if let Some((line, col)) = line_col {
|
if let Some((line, col)) = line_col {
|
||||||
info_!("at {:?}:{}:{}", White.paint(filename),
|
info_!("at line {}, column {}",
|
||||||
White.paint(line + 1), White.paint(col + 1));
|
Paint::default(line + 1).bold(), Paint::default(col + 1).bold());
|
||||||
} else {
|
|
||||||
info_!("in {:?}", White.paint(filename));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BadEnvVal(ref key, ref value, ref error) => {
|
BadEnvVal(ref key, ref value, ref error) => {
|
||||||
error!("environment variable '{}={}' could not be parsed",
|
error!("environment variable {} could not be parsed",
|
||||||
White.paint(key), White.paint(value));
|
Paint::default(format!("ROCKET_{}={}", key.to_uppercase(), value)).bold());
|
||||||
info_!("{}", White.paint(error));
|
info_!("{}", error);
|
||||||
}
|
}
|
||||||
UnknownKey(ref key) => {
|
UnknownKey(ref key) => {
|
||||||
error!("the configuration key '{}' is unknown and disallowed in \
|
error!("the configuration key {} is unknown and disallowed in \
|
||||||
this position", White.paint(key));
|
this position", Paint::default(key).bold());
|
||||||
}
|
}
|
||||||
Missing(ref key) => {
|
Missing(ref key) => {
|
||||||
error!("missing configuration key: '{}'", White.paint(key));
|
error!("missing configuration key: {}", Paint::default(key).bold());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,7 +207,7 @@ impl Drop for LaunchError {
|
||||||
LaunchErrorKind::FailedFairings(ref failures) => {
|
LaunchErrorKind::FailedFairings(ref failures) => {
|
||||||
error!("Rocket failed to launch due to failing fairings:");
|
error!("Rocket failed to launch due to failing fairings:");
|
||||||
for fairing in failures {
|
for fairing in failures {
|
||||||
info_!("{}", Paint::white(fairing));
|
info_!("{}", fairing);
|
||||||
}
|
}
|
||||||
|
|
||||||
panic!("launch fairing failure");
|
panic!("launch fairing failure");
|
||||||
|
|
|
@ -87,13 +87,13 @@ impl Fairings {
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(", ");
|
.join(", ");
|
||||||
|
|
||||||
info_!("{} {}: {}", Paint::white(num), kind, Paint::white(names));
|
info_!("{} {}: {}", Paint::default(num).bold(), kind, Paint::default(names).bold());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pretty_print_counts(&self) {
|
pub fn pretty_print_counts(&self) {
|
||||||
if !self.all_fairings.is_empty() {
|
if !self.all_fairings.is_empty() {
|
||||||
info!("{}{}:", Paint::masked("📡 "), Paint::purple("Fairings"));
|
info!("{}{}:", Paint::masked("📡 "), Paint::magenta("Fairings"));
|
||||||
self.info_for("launch", &self.launch);
|
self.info_for("launch", &self.launch);
|
||||||
self.info_for("request", &self.request);
|
self.info_for("request", &self.request);
|
||||||
self.info_for("response", &self.response);
|
self.info_for("response", &self.response);
|
||||||
|
|
|
@ -105,24 +105,25 @@ impl log::Log for RocketLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
// In Rocket, we abuse targets with suffix "_" to indicate indentation.
|
// In Rocket, we abuse targets with suffix "_" to indicate indentation.
|
||||||
|
let is_launch = record.target().starts_with("launch");
|
||||||
if record.target().ends_with('_') {
|
if record.target().ends_with('_') {
|
||||||
if configged_level != LoggingLevel::Critical || record.target().starts_with("launch") {
|
if configged_level != LoggingLevel::Critical || is_launch {
|
||||||
print!(" {} ", Paint::white("=>"));
|
print!(" {} ", Paint::default("=>").bold());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match record.level() {
|
match record.level() {
|
||||||
log::Level::Info => println!("{}", Paint::blue(record.args())),
|
log::Level::Info => println!("{}", Paint::blue(record.args()).wrap()),
|
||||||
log::Level::Trace => println!("{}", Paint::purple(record.args())),
|
log::Level::Trace => println!("{}", Paint::magenta(record.args()).wrap()),
|
||||||
log::Level::Error => {
|
log::Level::Error => {
|
||||||
println!("{} {}",
|
println!("{} {}",
|
||||||
Paint::red("Error:").bold(),
|
Paint::red("Error:").bold(),
|
||||||
Paint::red(record.args()))
|
Paint::red(record.args()).wrap())
|
||||||
}
|
}
|
||||||
log::Level::Warn => {
|
log::Level::Warn => {
|
||||||
println!("{} {}",
|
println!("{} {}",
|
||||||
Paint::yellow("Warning:").bold(),
|
Paint::yellow("Warning:").bold(),
|
||||||
Paint::yellow(record.args()))
|
Paint::yellow(record.args()).wrap())
|
||||||
}
|
}
|
||||||
log::Level::Debug => {
|
log::Level::Debug => {
|
||||||
print!("\n{} ", Paint::blue("-->").bold());
|
print!("\n{} ", Paint::blue("-->").bold());
|
||||||
|
|
|
@ -633,6 +633,6 @@ impl<S, E, F> fmt::Debug for Outcome<S, E, F> {
|
||||||
impl<S, E, F> fmt::Display for Outcome<S, E, F> {
|
impl<S, E, F> fmt::Display for Outcome<S, E, F> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let (color, string) = self.formatting();
|
let (color, string) = self.formatting();
|
||||||
write!(f, "{}", Paint::new(string).fg(color))
|
write!(f, "{}", Paint::default(string).fg(color))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,7 +247,7 @@ impl Rocket {
|
||||||
Outcome::Forward(data) => {
|
Outcome::Forward(data) => {
|
||||||
// There was no matching route. Autohandle `HEAD` requests.
|
// There was no matching route. Autohandle `HEAD` requests.
|
||||||
if request.method() == Method::Head {
|
if request.method() == Method::Head {
|
||||||
info_!("Autohandling {} request.", Paint::white("HEAD"));
|
info_!("Autohandling {} request.", Paint::default("HEAD").bold());
|
||||||
|
|
||||||
// Dispatch the request again with Method `GET`.
|
// Dispatch the request again with Method `GET`.
|
||||||
request._set_method(Method::Get);
|
request._set_method(Method::Get);
|
||||||
|
@ -290,7 +290,7 @@ impl Rocket {
|
||||||
|
|
||||||
// Check if the request processing completed or if the request needs
|
// Check if the request processing completed or if the request needs
|
||||||
// to be forwarded. If it does, continue the loop to try again.
|
// to be forwarded. If it does, continue the loop to try again.
|
||||||
info_!("{} {}", Paint::white("Outcome:"), outcome);
|
info_!("{} {}", Paint::default("Outcome:").bold(), outcome);
|
||||||
match outcome {
|
match outcome {
|
||||||
o@Outcome::Success(_) | o@Outcome::Failure(_) => return o,
|
o@Outcome::Success(_) | o@Outcome::Failure(_) => return o,
|
||||||
Outcome::Forward(unused_data) => data = unused_data,
|
Outcome::Forward(unused_data) => data = unused_data,
|
||||||
|
@ -392,26 +392,26 @@ impl Rocket {
|
||||||
}
|
}
|
||||||
|
|
||||||
launch_info!("{}Configured for {}.", Paint::masked("🔧 "), config.environment);
|
launch_info!("{}Configured for {}.", Paint::masked("🔧 "), config.environment);
|
||||||
launch_info_!("address: {}", Paint::white(&config.address));
|
launch_info_!("address: {}", Paint::default(&config.address).bold());
|
||||||
launch_info_!("port: {}", Paint::white(&config.port));
|
launch_info_!("port: {}", Paint::default(&config.port).bold());
|
||||||
launch_info_!("log: {}", Paint::white(config.log_level));
|
launch_info_!("log: {}", Paint::default(config.log_level).bold());
|
||||||
launch_info_!("workers: {}", Paint::white(config.workers));
|
launch_info_!("workers: {}", Paint::default(config.workers).bold());
|
||||||
launch_info_!("secret key: {}", Paint::white(&config.secret_key));
|
launch_info_!("secret key: {}", Paint::default(&config.secret_key).bold());
|
||||||
launch_info_!("limits: {}", Paint::white(&config.limits));
|
launch_info_!("limits: {}", Paint::default(&config.limits).bold());
|
||||||
|
|
||||||
match config.keep_alive {
|
match config.keep_alive {
|
||||||
Some(v) => launch_info_!("keep-alive: {}", Paint::white(format!("{}s", v))),
|
Some(v) => launch_info_!("keep-alive: {}", Paint::default(format!("{}s", v)).bold()),
|
||||||
None => launch_info_!("keep-alive: {}", Paint::white("disabled")),
|
None => launch_info_!("keep-alive: {}", Paint::default("disabled").bold()),
|
||||||
}
|
}
|
||||||
|
|
||||||
let tls_configured = config.tls.is_some();
|
let tls_configured = config.tls.is_some();
|
||||||
if tls_configured && cfg!(feature = "tls") {
|
if tls_configured && cfg!(feature = "tls") {
|
||||||
launch_info_!("tls: {}", Paint::white("enabled"));
|
launch_info_!("tls: {}", Paint::default("enabled").bold());
|
||||||
} else if tls_configured {
|
} else if tls_configured {
|
||||||
error_!("tls: {}", Paint::white("disabled"));
|
error_!("tls: {}", Paint::default("disabled").bold());
|
||||||
error_!("tls is configured, but the tls feature is disabled");
|
error_!("tls is configured, but the tls feature is disabled");
|
||||||
} else {
|
} else {
|
||||||
launch_info_!("tls: {}", Paint::white("disabled"));
|
launch_info_!("tls: {}", Paint::default("disabled").bold());
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.secret_key.is_generated() && config.environment.is_prod() {
|
if config.secret_key.is_generated() && config.environment.is_prod() {
|
||||||
|
@ -420,9 +420,8 @@ impl Rocket {
|
||||||
|
|
||||||
for (name, value) in config.extras() {
|
for (name, value) in config.extras() {
|
||||||
launch_info_!("{} {}: {}",
|
launch_info_!("{} {}: {}",
|
||||||
Paint::yellow("[extra]"),
|
Paint::yellow("[extra]"), name,
|
||||||
Paint::blue(name),
|
Paint::default(LoggedValue(value)).bold());
|
||||||
Paint::white(LoggedValue(value)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rocket {
|
Rocket {
|
||||||
|
@ -491,10 +490,11 @@ impl Rocket {
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn mount<R: Into<Vec<Route>>>(mut self, base: &str, routes: R) -> Self {
|
pub fn mount<R: Into<Vec<Route>>>(mut self, base: &str, routes: R) -> Self {
|
||||||
info!("{}{} '{}':",
|
info!("{}{} {}{}",
|
||||||
Paint::masked("🛰 "),
|
Paint::masked("🛰 "),
|
||||||
Paint::purple("Mounting"),
|
Paint::magenta("Mounting"),
|
||||||
Paint::blue(base));
|
Paint::blue(base),
|
||||||
|
Paint::magenta(":"));
|
||||||
|
|
||||||
let base_uri = Origin::parse(base)
|
let base_uri = Origin::parse(base)
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
|
@ -550,7 +550,7 @@ impl Rocket {
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn register(mut self, catchers: Vec<Catcher>) -> Self {
|
pub fn register(mut self, catchers: Vec<Catcher>) -> Self {
|
||||||
info!("{}{}:", Paint::masked("👾 "), Paint::purple("Catchers"));
|
info!("{}{}", Paint::masked("👾 "), Paint::magenta("Catchers:"));
|
||||||
for c in catchers {
|
for c in catchers {
|
||||||
if self.catchers.get(&c.code).map_or(false, |e| !e.is_default) {
|
if self.catchers.get(&c.code).map_or(false, |e| !e.is_default) {
|
||||||
info_!("{} {}", c, Paint::yellow("(warning: duplicate catcher!)"));
|
info_!("{} {}", c, Paint::yellow("(warning: duplicate catcher!)"));
|
||||||
|
@ -710,9 +710,9 @@ impl Rocket {
|
||||||
let full_addr = format!("{}:{}", self.config.address, self.config.port);
|
let full_addr = format!("{}:{}", self.config.address, self.config.port);
|
||||||
launch_info!("{}{} {}{}",
|
launch_info!("{}{} {}{}",
|
||||||
Paint::masked("🚀 "),
|
Paint::masked("🚀 "),
|
||||||
Paint::white("Rocket has launched from"),
|
Paint::default("Rocket has launched from").bold(),
|
||||||
Paint::white(proto).bold(),
|
Paint::default(proto).bold().underline(),
|
||||||
Paint::white(&full_addr).bold());
|
Paint::default(&full_addr).bold().underline());
|
||||||
|
|
||||||
// Restore the log level back to what it originally was.
|
// Restore the log level back to what it originally was.
|
||||||
logger::pop_max_level();
|
logger::pop_max_level();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::fmt::{self, Display};
|
use std::fmt::{self, Display};
|
||||||
use std::convert::From;
|
use std::convert::From;
|
||||||
|
|
||||||
use yansi::Color::*;
|
use yansi::Paint;
|
||||||
|
|
||||||
use codegen::StaticRouteInfo;
|
use codegen::StaticRouteInfo;
|
||||||
use handler::Handler;
|
use handler::Handler;
|
||||||
|
@ -282,19 +282,19 @@ impl Route {
|
||||||
|
|
||||||
impl fmt::Display for Route {
|
impl fmt::Display for Route {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "{} {}", Green.paint(&self.method), Blue.paint(&self.uri))?;
|
write!(f, "{} {}", Paint::green(&self.method), Paint::blue(&self.uri))?;
|
||||||
|
|
||||||
if self.rank > 1 {
|
if self.rank > 1 {
|
||||||
write!(f, " [{}]", White.paint(&self.rank))?;
|
write!(f, " [{}]", Paint::default(&self.rank).bold())?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ref format) = self.format {
|
if let Some(ref format) = self.format {
|
||||||
write!(f, " {}", Yellow.paint(format))?;
|
write!(f, " {}", Paint::yellow(format))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(name) = self.name {
|
if let Some(name) = self.name {
|
||||||
write!(f, " {}{}{}",
|
write!(f, " {}{}{}",
|
||||||
Cyan.paint("("), Purple.paint(name), Cyan.paint(")"))?;
|
Paint::cyan("("), Paint::magenta(name), Paint::cyan(")"))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in New Issue