c# NeutronLogger Part of the NeutronEngine Project.
NeutronLogger is a simple logging library for C++. It is designed to be easy to use and easy to integrate into your project. It is a part of the NeutronEngine project, but I like it so much I decided to make it a standalone library to be used in other projects.
My personal favourite feature of NeutronLogger is that it can catch exceptions such as segfaults and tell you where they happened. yay :)
Set the BOOST_STACKTRACE_USE_BACKTRACE define in your project to use the backtrace library.
Also set either COMPILE_DEBUG or COMPILE_RELEASE to compile the library in debug or release mode.
An example CMakelists.txt file:
project(NeutronExampleLogging DESCRIPTION "An example project for NeutronEngine made to show off Logging")
project(NeutronExampleLogging)
file(GLOB_RECURSE NEL_FILES "./NeutronExample/Logging/*")
include_directories(NeutronLogger/include)
add_executable(NeutronExampleLogging ${NEL_FILES})
target_link_libraries(NeutronExampleLogging NeutronEngine)
include_directories(NeutronEngine/Neutron/include)#include <Logger/Logger.h>
// using namespace Logger; // (if you do this, you can use the functions without the Logger:: prefix)
int main(int argc, char* argv[]) {
// Log some messages
Logger::Log("Hello World!");
Logger::Warn("This is a warning!", "Namespace");
Logger::Crit("This is a critical error!", "Namespace"); // critcial errors will not end the program execution, but will print a stack trace.
Logger::LogAt("This is another critical error!", Logger::Levels::CRIT, "Namespace"); // you can also use the LogAt function to log at a specific level.
Logger::Error("This is an error!", "Namespace"); // errors will end the program execution.
return 0;
}| Preprocessor Definition | Description |
|---|---|
| BOOST_STACKTRACE_USE_BACKTRACE | Used by boost_stacktrace and determines whether the backtrace is generated. Since Neutron Logger depends on the backtrace provided by boost_stacktrace, this needs to be set to get any backtrace functionality from the library. Unless being compiled in release mode, Neutron Logger will produce precompile warnings on the event this definition isn't found. |
| LOGGER_NO_INIT | If this is set, signal handlers won't be registered, and, if compiled in Realtime safe mode, the logging thread won't be started. |
| LOGGER_RT_SAFE | If this is set, the logging will realtime safe, meaning a new thread will be created for non realtime-safe logging operations. (DISCLAIMER: not fully RT safe yet) |
| LOGGER_VERBOSE | If this is set, the logger will log its own events, such as initialization. |