openframeworks / openframeworks/openFrameworks
Feature Request: verbose¬ice&warning&error&fatalError ---addColor..
Open
Nobody has claimed this yet.
core
feature
section-internals
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
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;
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating ofConsoleLoggerChannel::log and ofGetLogLevelName, then inspect how console logging is implemented across supported platforms. Compare the requested colors and level routing with the existing logger behavior. Done means log levels are visibly differentiated without disrupting the formatted message output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100