SA_Logger
Sapphire's Suite's C++ Logger.
Loading...
Searching...
No Matches
LogRAII.hpp
Go to the documentation of this file.
1// Copyright (c) 2023 Sapphire's Suite. All Rights Reserved.
2
3#pragma once
4
5#ifndef SAPPHIRE_LOGGER_LOG_RAII_GUARD
6#define SAPPHIRE_LOGGER_LOG_RAII_GUARD
7
9
20namespace SA
21{
26 class LogRAII
27 {
28 Log mHandle;
29
30 public:
36 LogRAII(Log&& _log);
37
40 };
41
43
44 #define __SA_SELECT_LOG_RAII_MACRO(_1, _2, _3, _4, _name, ...) _name
45
46 #define __SA_LOG_RAII4(_str, _lvl, _chan, _dets) __SA_CREATE_LOG(_str, _lvl, _chan, _dets)
47 #define __SA_LOG_RAII3(_str, _lvl, _chan) __SA_LOG_RAII4(_str, _lvl, _chan, L"")
48 #define __SA_LOG_RAII2(_str, _lvl) __SA_LOG_RAII3(_str, _lvl, Default)
49 #define __SA_LOG_RAII1(_str) __SA_LOG_RAII2(_str, Normal)
50
52
53#if defined(DOXYGEN)
54
69 #define SA_LOG_RAII((_str, _args), _lvl, _chan, _dets)
70
71#elif SA_DEBUG || SA_LOG_RELEASE_OPT
72
73 #define SA_LOG_RAII(...) SA::LogRAII __SA_EVAL_PASTE(__log_raii, __LINE__)(\
74 __SA_SELECT_LOG_RAII_MACRO(__VA_ARGS__, __SA_LOG_RAII4, __SA_LOG_RAII3, __SA_LOG_RAII2, __SA_LOG_RAII1)(__VA_ARGS__)\
75 );
76
77#else
78
79 #define SA_LOG_RAII(...) {}
80
81#endif
82
83}
84
85
88#endif // SAPPHIRE_LOGGER_LOG_RAII_GUARD
Log Helper Macros implementation.
Log type implementation.
Definition Log.hpp:25
Log RAII type implementation. Delays the log at the end of the scope.
Definition LogRAII.hpp:27
LogRAII(Log &&_log)
Construct RAII with log handle.
~LogRAII()
Destructor calling logger.