Logger Manager
Grail provides its own logger manager, which can be integrated into a game engine of your choice. The default logger is called "grail" and it shows messages related to the core library (for example: warning when a user passes improper config data). Default sink of "grail" logger is synchronized and writes info to standard output.
-
TRACE
-
DEBUG
-
INFO
-
WARNING
-
ERROR
-
CRITICAL - something is so wrong that after showing the message, the program should crash
Using the logger interface differs depending on the programming language you use.
Sinks
A sink is a form of output to which the logger writes. The user decides whether it is synchronized to prevent race conditions while running on multiple threads. While implementing custom sinks, the user should override the Log method.
Important interface
Usage
-
C++
-
C#
//access the logger manager singleton to create a new logger and add a sink
LoggerManager::GetInstance().CreateLogger("MyLoggerName");
LoggerManager::GetInstance().AddSinkToLogger("MyLoggerName", std::make_shared<MySink>()); //MySink should inherit from grail::logger::Sink
//macro accesing logger manager singleton and writing warning message to "grail" logger
GRAIL_LOG("grail", grail::logger::Severity::WARNING, "something went wrong") // C++ macro simplifying logger usage
//access the logger manager singleton to create a new logger and add a sink
LoggerManager.Instance.CreateLogger("MyLoggerName");
LoggerManager.Instance.AddSinkToLogger("MyLoggerName", new MySink()); //MySink should inherit from Grail.Logger.Sink
//logger manager singleton writing warning message to "grail" logger
LoggerManager.Log("grail", Severity.WARNING, "something went wrong");