Logs
About
Akel has a log system based on 4 levels of importance :
- Message : just a simple message that will be printed in blue in the console
- Warning : a warning message that will be printed in purple in the console
- Error : an error message that will be printed in red in the console but the program will continue to work
- Fatal Error : like the Error message but the program will be stop in emergency and will try to free all the allocator’s heaps for a safety exit
All messages are saved in a session file. Akel creates one per day and deletes those that are 10 days old or older.
Syntax
class CustomComponent : public Ak::Component
{
public:
void CustomComponent::onAttach() override
{
int i = 42;
Ak::Core::log::report(MESSAGE, "My message with var i = %d", i);
}
};
Member functions
Return type | Function | Specifiers |
---|---|---|
log() | explicit - delete |
|
~log() | delete |
|
void |
Init() | static |
void |
report(enum LogType type, std::string message, …) | static |
void |
report(std::string message, …) | static |
Constructor
Creates a new log system.
// Prototype
explicit log() = delete;
// Usage
// You can't use it because it is a deleted method.
// Log system is used like a static class.
// It is init automatically by Akel at the begenning of your program.
Destructor
Deletes the log system.
// Prototype
~log() = delete;
// Usage
// You can't use it because it is a deleted method.
// Log system is used like a static class.
// It is deleted automatically by Akel at the end of your program.
Init()
Inits the log system.
// Prototype
static void Init();
// Usage
// You are not supposed to use this method.
// It is init automatically by Akel at the begenning of your program.
report(enum LogType type, std::string message, …)
Sends a message the log system.
// Prototype
static void report(enum LogType type, std::string message, ...);
// Usage
Ak::Core::log::report(MESSAGE, "My message %s", "some var");
Ak::Core::log::report(WARNING, "My warning");
Ak::Core::log::report(ERROR, "My error");
Ak::Core::log::report(FATAL_ERROR, "My fatal error");
report(std::string message, …)
Sends a message the log system without level of importance and without console print. It is used only for adding message in the session’s file.
// Prototype
static void report(std::string message, ...);
// Usage
Ak::Core::log::report("My message");
Other functions
Return type | Function | Specifiers |
---|---|---|
void |
Message(std::string message, …) | None |
void |
Warning(std::string message, …) | None |
void |
Error(std::string message, …) | None |
void |
FatalError(std::string message, …) | None |
Message(std::string message, …)
Sends a message the log system.
// Prototype
void Message(std::string message, ...);
// Usage
Ak::Core::Message("My message");
Warning(std::string message, …)
Sends a warning the log system.
// Prototype
void Warning(std::string message, ...);
// Usage
Ak::Core::Warning("My warning");
Error(std::string message, …)
Sends an error the log system.
// Prototype
void Error(std::string message, ...);
// Usage
Ak::Core::Error("My error");
FatalError(std::string message, …)
Sends a fatal error the log system.
// Prototype
void FatalError(std::string message, ...);
// Usage
Ak::Core::FatalError("My fatal error");