Skip to content
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

Support ROSCONSOLE_FORMAT #152

Open
lucasw opened this issue Nov 21, 2020 · 1 comment
Open

Support ROSCONSOLE_FORMAT #152

lucasw opened this issue Nov 21, 2020 · 1 comment

Comments

@lucasw
Copy link
Contributor

lucasw commented Nov 21, 2020

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.

@lucasw
Copy link
Contributor Author

lucasw commented Nov 26, 2020

This is mostly working in https://github.com/lucasw/rosrust/tree/rosconsole_format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant