Cinder-ImGui icon indicating copy to clipboard operation
Cinder-ImGui copied to clipboard

Add cinder logger

Open heisters opened this issue 8 years ago • 2 comments

Usage:

MyApp::MyApp()
{
    log::makeLogger< ui::Logger >();
}

void MyApp::update() {
    for ( auto & log : log::manager()->getLoggers< ui::Logger >() ) {
        log->draw( "Log" );
    }
}

heisters avatar Feb 17 '17 19:02 heisters

Sounds really cool. Not sure I understand what's happening in your example's MyApp::update. Does it create a window named "Log" for each log?

simongeilfus avatar Feb 17 '17 20:02 simongeilfus

My understanding of LogManager::getLoggers is that it will only return registered loggers of the passed type. So, since the user only registered one ui::Logger, the getLoggers call would only return one logger. If the user registered more than one ui::Logger at initialization, they would need to adapt the code to label each window uniquely. Perhaps a clearer example would be:

void MyApp::update() {
    log::manager()->getLoggers< ui::Logger >()[ 0 ]->draw( "Log" );
}

That window will include all messages that the ui::Logger is configured to log, which is configurable with something like:

log::manager()->getLoggers< ui::Logger >()[ 0 ]->setLoggingLevel( log::LEVEL_ERROR );

Lastly, you could, of course, avoid the whole getLoggers dance if you do something like this in initialization:

std::shared_ptr< ui::Logger > m_uiLogger;
// ...
m_uiLogger = log::makeLogger< ui::Logger >();

Does that answer your question?

heisters avatar Feb 17 '17 20:02 heisters