text
stringlengths 0
2.2M
|
---|
return "warning";
|
case OF_LOG_ERROR:
|
return pad ? " error " : "error";
|
case OF_LOG_FATAL_ERROR:
|
return pad ? " fatal " : "fatal";
|
case OF_LOG_SILENT:
|
return pad ? "silent " : "silent";
|
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 << "[" << ofGetLogLevelName(level, true) << "] ";
|
// only print the module name if it's not ""
|
if(module != ""){
|
out << module << ": ";
|
}
|
out << message << endl;
|
}
|
void ofConsoleLoggerChannel::log(ofLogLevel level, const string & module, const char* format, ...){
|
va_list args;
|
va_start(args, format);
|
log(level, module, format, args);
|
va_end(args);
|
}
|
void ofConsoleLoggerChannel::log(ofLogLevel level, const string & module, const char* format, va_list args){
|
//thanks stefan!
|
//http://www.ozzu.com/cpp-tutorials/tutorial-writing-custom-printf-wrapper-function-t89166.html
|
FILE* out = level < OF_LOG_ERROR ? stdout : stderr;
|
fprintf(out, "[%s] ", ofGetLogLevelName(level, true).c_str());
|
if(module != ""){
|
fprintf(out, "%s: ", module.c_str());
|
}
|
vfprintf(out, format, args);
|
fprintf(out, "\n");
|
}
|
#ifdef TARGET_WIN32
|
#include <array>
|
void ofDebugViewLoggerChannel::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
|
stringstream out;
|
out << "[" << ofGetLogLevelName(level, true) << "] ";
|
// only print the module name if it's not ""
|
if (module != "") {
|
out << module << ": ";
|
}
|
out << message << endl;
|
OutputDebugStringA(out.str().c_str());
|
}
|
void ofDebugViewLoggerChannel::log(ofLogLevel level, const string & module, const char* format, ...) {
|
va_list args;
|
va_start(args, format);
|
log(level, module, format, args);
|
va_end(args);
|
}
|
void ofDebugViewLoggerChannel::log(ofLogLevel level, const string & module, const char* format, va_list args) {
|
std::string buffer;;
|
buffer = "[" + ofGetLogLevelName(level, true) + "] ";
|
if (module != "") {
|
buffer += module + ": ";
|
}
|
buffer += ofVAArgsToString(format, args);
|
buffer += "\n";
|
OutputDebugStringA(buffer.c_str());
|
}
|
#endif
|
//--------------------------------------------------
|
ofFileLoggerChannel::ofFileLoggerChannel(){
|
}
|
ofFileLoggerChannel::ofFileLoggerChannel(const std::filesystem::path & path, bool append){
|
setFile(path,append);
|
}
|
ofFileLoggerChannel::~ofFileLoggerChannel(){
|
close();
|
}
|
void ofFileLoggerChannel::close(){
|
file.close();
|
}
|
void ofFileLoggerChannel::setFile(const std::filesystem::path & path,bool append){
|
file.open(path,append?ofFile::Append:ofFile::WriteOnly);
|
file << endl;
|
file << endl;
|
file << "--------------------------------------- " << ofGetTimestampString() << endl;
|
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.