void ofConsoleLoggerChannel::log(ofLogLevel logLevel, 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
	if(logLevel<OF_LOG_ERROR){
		printf("%s: ", module.c_str());
		printf("%s: ", ofGetLogLevelName(logLevel).c_str());
		vprintf( format, args );
		printf("\n");
	}else{
		fprintf(stderr,"%s: ", module.c_str());
		fprintf(stderr,"%s: ", ofGetLogLevelName(logLevel).c_str());
		vfprintf( stderr, format, args );
		fprintf(stderr,"\n");
	}
}
Exemple #2
0
void ofFileLoggerChannel::log(ofLogLevel level, const string & module, const char* format, va_list args){
	file << "[" << ofGetLogLevelName(level, true) << "] ";
	if(module != ""){
		file << module << ": ";
	}
	file << ofVAArgsToString(format,args) << endl;
}
Exemple #3
0
void ofFileLoggerChannel::log(ofLogLevel level, const string & module, const string & message){
	file << "[" << ofGetLogLevelName(level, true) << "] ";
	if(module != ""){
		file << module << ": ";
	}
	file << message << endl;
}
Exemple #4
0
//--------------------------------------------------
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;
}
Exemple #5
0
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");
}
//--------------------------------------------------------------
void ofxScreenLoggerChannel::log(ofLogLevel level, const string & module, const char* format, va_list args)
{
    // Compose the message.
    std::ostringstream oss;
    if (_bPrefixTimestamp) {
        oss << ofGetTimestampString("%H:%M:%S:%i") << " ";
    }
    oss << "[" << ofGetLogLevelName(level, true) << "] ";
    if (module != "") {
        oss << module << ": ";
    }
    oss << ofVAArgsToString(format, args) << endl;
    
    // Add it to the buffer.
    _buffer.push_front(oss.str());
    
    // Adjust offset if necessary.
    if (_scrollOffset > 0) ++_scrollOffset;
    
    // Erase older messages.
    while (_buffer.size() > _maxBufferCount) {
        _buffer.pop_back();
    }
}
void ofFileLoggerChannel::log(ofLogLevel logLevel, const string & module, const char* format, va_list args){
	file << module << ": " << ofGetLogLevelName(logLevel) << ": ";
	file << ofVAArgsToString(format,args) << endl;
}
void ofFileLoggerChannel::log(ofLogLevel level, const string & module, const string & message){
	file << module << ": " << ofGetLogLevelName(level) << ": " << message << endl;
}
void ofConsoleLoggerChannel::log(ofLogLevel level, const string & module, const string & message){
	if(level<OF_LOG_ERROR) cout << module << ": " << ofGetLogLevelName(level) << ": " << message << endl;
	else cerr << module << ": " << ofGetLogLevelName(level) << ": " << message << endl;
}