rosrust
rosrust copied to clipboard
Support ROSCONSOLE_FORMAT
I'm going to take this on myself to learn more about rust and rosrust.
http://wiki.ros.org/rosconsole#Console_Output_Formatting
This looks like the code to modify in rosrust/src/api/ros.rs
:
fn log_to_terminal(&self, level: i8, msg: &str, file: &str, line: u32) {
use colored::{Color, Colorize};
let format_string =
|prefix, color| format!("[{} @ {}:{}]: {}", prefix, file, line, msg).color(color);
match level {
Log::DEBUG => println!("{}", format_string("DEBUG", Color::White)),
Log::INFO => println!("{}", format_string("INFO", Color::White)),
Log::WARN => eprintln!("{}", format_string("WARN", Color::Yellow)),
Log::ERROR => eprintln!("{}", format_string("ERROR", Color::Red)),
Log::FATAL => eprintln!("{}", format_string("FATAL", Color::Red)),
_ => {}
}
}
Mine for example is:
[${severity}][${time} ${file}:${line} ${node}]: ${message}
It shouldn't be too hard to read the environmental variable and then convert it to a eprintln compatible format_string.
This is mostly working in https://github.com/lucasw/rosrust/tree/rosconsole_format