Skip to content

Commit 0b0c425

Browse files
committed
Add first logger version
1 parent 201c815 commit 0b0c425

File tree

2 files changed

+59
-11
lines changed

2 files changed

+59
-11
lines changed

code/Common/Logger.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
/*-----------------------------------------------------------------------------------------------
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2014-2025 Kim Kulling
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
this software and associated documentation files (the "Software"), to deal in
8+
the Software without restriction, including without limitation the rights to
9+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
the Software, and to permit persons to whom the Software is furnished to do so,
11+
subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
-----------------------------------------------------------------------------------------------*/
123
#include <cppcore/Common/Logger.h>
224
#include <cassert>
325
#include <iomanip>

include/cppcore/Common/Logger.h

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
/*-----------------------------------------------------------------------------------------------
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2014-2025 Kim Kulling
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
this software and associated documentation files (the "Software"), to deal in
8+
the Software without restriction, including without limitation the rights to
9+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
the Software, and to permit persons to whom the Software is furnished to do so,
11+
subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
-----------------------------------------------------------------------------------------------*/
123
#pragma once
224

325
#include <cppcore/CPPCoreCommon.h>
@@ -63,16 +85,20 @@ class Logger final {
6385
public:
6486
/// @brief Describes the verbode mode.
6587
enum class VerboseMode {
66-
Normal, ///< Only warnings and errors will be logged.
67-
Verbose, ///< Normal messages will be logged as well.
68-
Debug, ///< All debug messages will be logged as well.
69-
Trace ///< Will enable the tracing.
88+
Invalid = -1, ///< Invalid marker
89+
Normal, ///< Only warnings and errors will be logged.
90+
Verbose, ///< Normal messages will be logged as well.
91+
Debug, ///< All debug messages will be logged as well.
92+
Trace, ///< Will enable the tracing.
93+
Count ///< Number of enums
7094
};
7195

7296
/// @brief Describes the mode for prints into the active log stream.
7397
enum class PrintMode {
98+
Invalid = -1, ///< Invalid marker
7499
WithDateTime, ///< A dateTime string will put be in front of the entry.
75-
WhithoutDateTime ///< No DateTime will be there.
100+
WhithoutDateTime, ///< No DateTime will be there.
101+
Count ///< Number of enums
76102
};
77103

78104
public:
@@ -183,44 +209,44 @@ void fatalPrint( const String &domain, const String &file, int line, const Strin
183209
/// @param domain The domain to log for.
184210
/// @param message The message to log.
185211
//-------------------------------------------------------------------------------------------------
186-
#define log_trace(domain, msg) cppcore::tracePrint(domain, __FILE__, __LINE__, msg)
212+
#define log_trace(domain, msg) ::cppcore::tracePrint(domain, __FILE__, __LINE__, msg)
187213

188214
//-------------------------------------------------------------------------------------------------
189215
/// @fn osre_debug
190216
/// @brief This helper macro will write the debug message into the logger.
191217
/// @param domain The domain to log for.
192218
/// @param message The message to log.
193219
//-------------------------------------------------------------------------------------------------
194-
#define log_debug(domain, msg) cppcore::debugPrint( domain, __FILE__, __LINE__, msg)
220+
#define log_debug(domain, msg) ::cppcore::debugPrint(domain, __FILE__, __LINE__, msg)
195221

196222
//-------------------------------------------------------------------------------------------------
197223
/// @fn osre_log
198224
/// @brief This helper macro will write the info message into the logger.
199225
/// @param domain The domain to log for.
200226
/// @param message The message to log.
201227
//-------------------------------------------------------------------------------------------------
202-
#define log_info(domain, msg) cppcore::infoPrint( domain, __FILE__, __LINE__, msg)
228+
#define log_info(domain, msg) ::cppcore::infoPrint(domain, __FILE__, __LINE__, msg)
203229

204230
//-------------------------------------------------------------------------------------------------
205231
/// @fn osre_warn
206232
/// @brief This helper macro will write a warning into the logger.
207233
/// @param domain The domain to log for.
208234
/// @param message The warning to writhe into the log.
209235
//-------------------------------------------------------------------------------------------------
210-
#define log_warn(domain, message) cppcore::warnPrint( domain, __FILE__, __LINE__, message)
236+
#define log_warn(domain, message) ::cppcore::warnPrint(domain, __FILE__, __LINE__, message)
211237

212238
//-------------------------------------------------------------------------------------------------
213239
/// @fn osre_error
214240
/// @brief This helper macro will write a error into the logger.
215241
/// @param domain The domain to log for.
216242
/// @param message The warning to writhe into the log.
217243
//-------------------------------------------------------------------------------------------------
218-
#define log_error(domain, message) cppcore::errorPrint( domain, __FILE__, __LINE__, message)
244+
#define log_error(domain, message) ::cppcore::errorPrint(domain, __FILE__, __LINE__, message)
219245

220246
//-------------------------------------------------------------------------------------------------
221247
/// @fn osre_fatal
222248
/// @brief This helper macro will write a fatal error into the logger.
223249
/// @param domain The domain to log for.
224250
/// @param message The warning to writhe into the log.
225251
//-------------------------------------------------------------------------------------------------
226-
#define log_fatal( domain, message ) cppcore::fatalPrint( domain,__FILE__, __LINE__, message)
252+
#define log_fatal(domain, message) ::cppcore::fatalPrint(domain, __FILE__, __LINE__, message)

0 commit comments

Comments
 (0)