|
|
|
LagerUsing the Lager is pretty simple, you initialize the singleton LogServer for a thread, then you just use some macros to define scope and log messages. Here's a full program to illustrate the point:
#include "../../LogServer.h"
#include "../../Lager.h"
using namespace Lager;
void Func1();
void Func2();
int main( int argc, char** argv )
{
LogServer::Instance().InitializeThread( "TestFile.xml", "Test program for the Lager system" );
LogServer::Instance().SetLogLevel( Lager::LOW );
Func1();
Func2();
LogServer::Instance().ShutdownThread();
return 1;
}
void Func1()
{
LOG_SCOPE_LOW( "Func1", "testing 1 2 3 " << 4 );
LOG_LOW( "DEVELOPER Test log entry 1 Func1" );
Func2();
LOG_MID( "GEEK Test log entry 2 Func1" );
}
void Func2()
{
LOG_SCOPE( "Func2" );
LOG_LOW( "DEVELOPER Test log entry 1 Func2" );
LOG_HIGH( "USER Test log entry 2 Func2" );
}
The above program will produce this xml file. The Lager can be compiled into two libraries, a threaded and a non-threaded one. The threaded version keeps thread information in a std::vector and it uses thread local storage to index it. Because of this it isn't incredibly efficient. The non-threaded version doesn't incur this overhead. The included solution/workspace files let you build both versions. If you're using the threaded version you must define THREADED_LAGER in your project. You can download the Lager source here. It includes 3 subdirectories:
|