gameoverhack / ofxLogger

Simple logging addon for openFrameworks
Other
6 stars 6 forks source link

writing to file needs to be activated to work? #1

Open emmanuelgeoffray opened 11 years ago

emmanuelgeoffray commented 11 years ago

Hello, Thanks for this addon with really good features required when logging messages.

I'm facing an issue, and I'm not sure if I'm doing smthg wrong or if the behavior is expected. I'm testing this:

 ofxLogSetLogLevel(LOG_NOTICE);

    ofxLog(LOG_VERBOSE, "Setting up and logging bracket style");

    ofxLog(LOG_NOTICE) << "Logging 'cout' style" << endl;

    ofxLogNotice() << "You can log to a file" << endl;

    ofxLogSetLogToFile(true);  // defaults to log.txt in your data path

    // ofxLogSetLogToFile(true, ofToDataPath("somepath/logName.txt") lets you set a custom path
    // OR
    // ofxLogSetLogFilePath(ofToDataPath("somepath/logName.txt"));
    ofxLogSetLogOptions(LOG_USE_TIME | LOG_USE_CALL | LOG_USE_TYPE | LOG_USE_PADD | LOG_USE_FILE);
    // see below for option settings

    ofxLogNotice() << "You can set different options for the log messages" << endl;

    //ofxLogSetLogOptions(LOG_USE_TIME | LOG_USE_CALL | LOG_USE_TYPE | LOG_USE_PADD);
    ofxLogNotice() << "After options" << endl;

That doesn't write anything to log.txt. But if I uncomment the last ofxLogSetLogOptions, text before this line is written to file.

What can I do to keep logging into file without disabling it?

Thank you! Best, Emmanuel

emmanuelgeoffray commented 11 years ago

(tested on linux)

For now, I close the file in exit:

//--------------------------------------------------------------
void testApp::exit(){
    ofxLogSetLogOptions(LOG_USE_TIME | LOG_USE_CALL | LOG_USE_TYPE | LOG_USE_PADD);
}

here's the closing log:

Key pressed 27
Closing log file

That works if the application is correclty closed but won't if it crashes.

emmanuelgeoffray commented 11 years ago

@gameoverhack any hint on this?

gameoverhack commented 11 years ago

hey emmanuel - sorry I missed this issue...hmmm...it's different behaviour on windows and mac I think - I don't need to manually close the file for it to have written. I say "i think" because I actually have not tested the last line output to see what I get.

I'll have a look.