Cinder-ImGui
Cinder-ImGui copied to clipboard
Add cinder logger
Usage:
MyApp::MyApp()
{
log::makeLogger< ui::Logger >();
}
void MyApp::update() {
for ( auto & log : log::manager()->getLoggers< ui::Logger >() ) {
log->draw( "Log" );
}
}
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?
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?