text
stringlengths
0
2.2M
//--------------------------------------------------
ofLog::ofLog(){
level = OF_LOG_NOTICE;
module = "";
bPrinted = false;
}
//--------------------------------------------------
ofLog::ofLog(ofLogLevel _level){
level = _level;
module = "";
bPrinted = false;
}
//--------------------------------------------------
ofLog::ofLog(ofLogLevel level, const string & message){
_log(level,"",message);
bPrinted = true;
}
//--------------------------------------------------
ofLog::ofLog(ofLogLevel level, const char* format, ...){
if(checkLog(level,"")){
va_list args;
va_start( args, format );
channel()->log(level,"",format,args);
va_end( args );
}
bPrinted = true;
}
//--------------------------------------------------
void ofLog::setAutoSpace(bool autoSpace){
bAutoSpace = autoSpace;
if(bAutoSpace){
ofLog::getPadding() = " ";
}
else{
ofLog::getPadding() = "";
}
}
//-------------------------------------------------------
ofLog::~ofLog(){
// don't log if we printed in the constructor already
if(!bPrinted){
_log(level,module,message.str());
}
}
bool ofLog::checkLog(ofLogLevel level, const string & module){
if(getModules().find(module)==getModules().end()){
if(level >= currentLogLevel) return true;
}else{
if(level >= getModules()[module]) return true;
}
return false;
}
//-------------------------------------------------------
void ofLog::_log(ofLogLevel level, const string & module, const string & message){
if(checkLog(level,module)){
channel()->log(level,module, message);
}
}
//--------------------------------------------------
ofLogVerbose::ofLogVerbose(const string & _module){
level = OF_LOG_VERBOSE;
module = _module;
bPrinted=false;
}
ofLogVerbose::ofLogVerbose(const string & _module, const string & _message){
_log(OF_LOG_VERBOSE,_module,_message);
bPrinted = true;
}
ofLogVerbose::ofLogVerbose(const string & module, const char* format, ...){
if(checkLog(OF_LOG_VERBOSE, module)){
va_list args;
va_start(args, format);
channel()->log(OF_LOG_VERBOSE, module, format, args);
va_end(args);
}
bPrinted = true;
}
//--------------------------------------------------
ofLogNotice::ofLogNotice(const string & _module){
level = OF_LOG_NOTICE;
module = _module;
bPrinted=false;
}
ofLogNotice::ofLogNotice(const string & _module, const string & _message){
_log(OF_LOG_NOTICE,_module,_message);
bPrinted = true;
}