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

Feature Request: verbose&notice&warning&error&fatalError ---addColor.. #2424

Open
yty opened this issue Aug 8, 2013 · 4 comments
Open

Feature Request: verbose&notice&warning&error&fatalError ---addColor.. #2424

yty opened this issue Aug 8, 2013 · 4 comments

Comments

@yty
Copy link

yty commented Aug 8, 2013

I think it should be better to differentiate log files.
How do you think about it?

verbose->blur
notice->green
warning->Orange
error ->darkred
fatalError ->red

string ofGetLogLevelName(ofLogLevel level){
    HANDLE hCout = GetStdHandle(STD_OUTPUT_HANDLE); 

    switch(level){
        case OF_LOG_VERBOSE:
            SetConsoleTextAttribute(hCout,FOREGROUND_BLUE );
            return "verbose";
            break;
        case OF_LOG_NOTICE:
            SetConsoleTextAttribute(hCout,FOREGROUND_GREEN );
            return "notice";
            break;
        case OF_LOG_WARNING:
            SetConsoleTextAttribute(hCout,FOREGROUND_RED|FOREGROUND_GREEN );
            return "warning";
            break;
        case OF_LOG_ERROR:
            SetConsoleTextAttribute(hCout,FOREGROUND_RED );
            return "error";
            break;
        case OF_LOG_FATAL_ERROR:
            SetConsoleTextAttribute(hCout,FOREGROUND_RED|FOREGROUND_INTENSITY );
            return "fatal error";
            break;
        case OF_LOG_SILENT:
            return "silent";
            break;
        default:
            return "";
    }
}

void ofConsoleLoggerChannel::log(ofLogLevel level, const string & module, const string & message){
    // print to cerr for OF_LOG_ERROR and OF_LOG_FATAL_ERROR, everything else to cout 
    ostream& out = level < OF_LOG_ERROR ? cout : cerr;
    out << "[";
    // only print the module name if it's not "OF"
    if(module != "OF") {
        out << module << ":";
    }
    HANDLE hCout = GetStdHandle(STD_OUTPUT_HANDLE); 

    out << ofGetLogLevelName(level);
    SetConsoleTextAttribute(hCout,FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE );
    out<< "] "<< message << endl;
}   
@bilderbuchi
Copy link
Member

have you tried the logging system very recently? we improved the layout so that logging messages can be distinguished better, check it out on develop!

@yty
Copy link
Author

yty commented Aug 13, 2013

@ bilderbuchi

Adding color is not good?

@bilderbuchi
Copy link
Member

not if it's not really necessary in the first place, gets lost when saving logging to file anyway, is a platform-specific implementation.

@Teatoller
Copy link

The issue at hand here was one of striking a consensus. That is on the use of color styling to differentiate for verbose, notice, warnings, and error, or fatal error messages.
It is NOT a bug.
There has been no conclusive decision on this for close to 8 years.
May we close this issue and reopen it when needed.

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

No branches or pull requests

3 participants