Faro Engine 0.0.0.b519570 (main)
Loading...
Searching...
No Matches
Log.hpp
Go to the documentation of this file.
1#pragma once
5
6namespace Faro
7{
8 /// @brief Logging category
10 {
11 LC_Trace, ///< Tracing category. Provides in-depth insight of a sequence of events. Not visible to the end user.
12 LC_Debug, ///< Debugging category. Shows debug info. Not visible to the end user.
13 LC_Info, ///< Info category. Communicates generic informative messages.
14 LC_Warning, ///< Warning category. Reports potential issues.
15 LC_Error, ///< Error category. Reports issues.
16 LC_Fatal ///< Fatal category. Reports critical issues. This will also stop execution of the application.
17 };
18
19 /// @brief Defines a logging tag. To be defined and declared with LOG_DEFINITION and LOG_DECLARATION.
20 struct LogTag
21 {
23
24 /**
25 * @brief Log a message with this tag
26 * @param category Log category
27 * @param format Format string
28 * @param ... List of argument to be used for formatting
29 */
30 void Log(LogCategory category, String format, ...);
31
32 /// @brief Name of this log tag
34 };
35
36#define LOG_DEFINITION(Tag) extern LogTag Tag;
37#define LOG_DECLARATION(Tag, Header) LogTag Tag(#Header);
38
39 /// @internal
46
48 {
49 public:
50 /// @brief Logging callback that is executed by Logger.
51 virtual void Log(const LogMessage& message) = 0;
52 };
53
54 /// @brief Class responsible for all logging related functionality.
55 class Logger
56 {
57 public:
58 static void Init();
59
60 static void Destroy();
61
62 /**
63 * @brief Log a messages with the provided format string and variadic argument list.
64 * @param tag Log tag
65 * @param category Log category
66 * @param format Format string
67 * @param arguments Variadic argument list to be used for formatting
68 */
69 static void LogVA(const LogTag& tag, LogCategory category, String format, va_list arguments);
70
71 /**
72 * @brief Log a messages with the provided format string and arguments.
73 * @param tag Log tag
74 * @param category Log category
75 * @param format Format string
76 * @param ... List of argument to be used for formatting
77 */
78 static void Log(const LogTag& tag, LogCategory category, String format, ...);
79
80 private:
81 static Array<ILogSink*> logSinks;
82 };
83
85 #define REGISTER_LOGSINK(SINK) REGISTER_INSTANCE(LogSinks, SINK)
86}
#define DEFINE_INSTANCE_REGISTRY(NAME, TYPE)
Definition ClassRegistry.hpp:6
Definition Array.hpp:11
Definition Log.hpp:48
virtual void Log(const LogMessage &message)=0
Logging callback that is executed by Logger.
Class responsible for all logging related functionality.
Definition Log.hpp:56
static void LogVA(const LogTag &tag, LogCategory category, String format, va_list arguments)
Log a messages with the provided format string and variadic argument list.
Definition Log.cpp:34
static void Destroy()
Definition Log.cpp:29
static void Log(const LogTag &tag, LogCategory category, String format,...)
Log a messages with the provided format string and arguments.
Definition Log.cpp:49
static void Init()
Definition Log.cpp:24
Definition String.hpp:12
Definition Array.hpp:8
LogCategory
Logging category.
Definition Log.hpp:10
@ LC_Warning
Warning category. Reports potential issues.
Definition Log.hpp:14
@ LC_Debug
Debugging category. Shows debug info. Not visible to the end user.
Definition Log.hpp:12
@ LC_Info
Info category. Communicates generic informative messages.
Definition Log.hpp:13
@ LC_Trace
Tracing category. Provides in-depth insight of a sequence of events. Not visible to the end user.
Definition Log.hpp:11
@ LC_Fatal
Fatal category. Reports critical issues. This will also stop execution of the application.
Definition Log.hpp:16
@ LC_Error
Error category. Reports issues.
Definition Log.hpp:15
Definition Log.hpp:41
String message
Definition Log.hpp:44
const LogTag & tag
Definition Log.hpp:42
LogCategory category
Definition Log.hpp:43
Defines a logging tag. To be defined and declared with LOG_DEFINITION and LOG_DECLARATION.
Definition Log.hpp:21
void Log(LogCategory category, String format,...)
Log a message with this tag.
Definition Log.cpp:16
String name
Name of this log tag.
Definition Log.hpp:33