-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
console: configurable log levels, file logging (#359) #488
Conversation
Current status: this works, logging to client.log in the configuration directory (as of #486, this is either the current working directory -or-:
), and to the terminal (now with color). But now nothing logs to the in-game console, nor the browser console (for #446 web). And configurable log levels would be nice, instead of hardcoding trace (add options in conf.cfg?). In particular, the terminal log output could have a lower log level to reduce console overhead, but keep the file log level higher (trace? debug?) for diagnosing problems after they happen. Also allow disabling terminal colors, if it causes problems (TermLogger -> SimpleLogger, depending on a config option). Maybe stop logging to the in-game console, and use it instead for #479 chat, and other client/server messages. It has a different purpose than diagnostic logging (trace/debug/info/warn/error). |
It was more straightforward to extend our existing logger backend than switch out to another logging system. Added file logging and configurable log levels (edit in conf.cfg). The default of Removing logging to the in-game console can come later, after #479 chat. Adding colors to the terminal output would be nice too, just like there are in the in-game console, using TextComponents (but not strictly necessary. convert the TextComponents to ANSI codes?): let mut msg = TextComponent::new("");
msg.modifier.extra = Some(vec![
Component::Text(TextComponent::new("[")),
{
let mut msg = TextComponent::new(file);
msg.modifier.color = Some(Color::Green);
Component::Text(msg)
},
Component::Text(TextComponent::new(":")),
{
let mut msg = TextComponent::new(&format!("{}", record.line().unwrap_or(0)));
msg.modifier.color = Some(Color::Aqua);
Component::Text(msg)
},
Component::Text(TextComponent::new("]")),
Component::Text(TextComponent::new("[")),
{
let mut msg = TextComponent::new(&format!("{}", record.level()));
msg.modifier.color = Some(match record.level() {
log::Level::Debug => Color::Green,
log::Level::Error => Color::Red,
log::Level::Warn => Color::Yellow,
log::Level::Info => Color::Aqua,
log::Level::Trace => Color::Blue,
});
Component::Text(msg)
},
Component::Text(TextComponent::new("] ")),
Component::Text(TextComponent::new(&format!("{}", record.args()))),
]); |
No description provided.