logog
logger optimized for games
|
The logog system is a set of C++ header files and C++ source files. To use them, compile all the C++ source files into a single library. The compiler will need to reference the files in the include directory when compiling the logog library.
To make this easier, logog has been set up to compile using CMake, available at http://www.cmake.org/ . CMake is a free cross-platform build system, and executables are available for most major platforms and development environments. Download and install CMake in order to generate a build for your platform.
For example, to build the project and libraries on Visual Studio 2017, find and launch the Visual Studio 2017 Command Prompt at Microsoft Visual Studio 2017 / Visual Studio Tools / Visual Studio 2017 Command Prompt.
Then, to create the appropriate project files, create an empty directory, make that directory the current directory, and run the CMake command with the logog directory as a parameter:
At this point, your directory will contain appropriate project and solution files for your platform. Once the solution is building, the CMake program is no longer needed. Compile and link the library for your own platform using the makefile or project files generated for your platform.
Here is a working logog example that initializes logog, outputs some sample messages and then terminates.
The most common mistake when getting started with logog is creating a Cerr or Cout object and not destroying the object before LOGOG_SHUTDOWN(). This is a usage error and will be detected as heap corruption by most debuggers.
To use the logging library in your own project, put the following line at the top of your source file(s):
Additionally, make sure to add logog's /include path into the directories your build process searches.
At the beginning of your program, initialize logog exactly once, with this macro:
To tell logog what type of output should be logged, you must first create a logog::Cerr, a logog::Cout, or a logog::LogFile object. Once this object is instantiated, all messages will be routed to that target. For example:
Or:
It's only necessary to create one target per process, immediately after initializing logog; you don't need to instance a different Cout, Cerr or LogFile for each class or each file.
To log a message in your code, use one of the following macros, in order of severity. Arguments are assumed to be sprintf-style varargs:
Note the funny spellings on DBUG and ERR to avoid conflicting with existing macros on Windows platforms.
If it turns out that the names of these macros conflict with your existing code, then before including the logog.hpp file, define the following constant:
If you enable that prefix, you may log with the following macros instead:
An example usage follows:
At this point, your Target object (in this case, the errOutput object) should be destroyed. Falling out of scope is the easiest way to achieve this.
Then, terminate your program and logging with the following message:
Lastly, compile and link with the logog library you created earlier.