 |
SWC-DB
v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
|
Go to the documentation of this file.
7 #ifndef swcdb_core_Logger_h
8 #define swcdb_core_Logger_h
44 #define SWC_LOG_OSTREAM std::cout
53 static std::string
repr(uint8_t priority);
77 void daemon(const std::
string& logs_path);
80 const std::
string&
name() const noexcept {
104 void log(uint8_t priority,
const char* fmt, ...)
107 void log(uint8_t priority, const
char* filen,
int fline,
108 const
char* fmt, ...)
112 SWC_SHOULD_NOT_INLINE
113 void msg(uint8_t priority, const
T&
msg) noexcept {
122 SWC_SHOULD_NOT_INLINE
123 void msg(uint8_t priority,
const char* filen,
int fline,
124 const T&
msg) noexcept {
132 void _print_prefix(uint8_t priority,
const char* filen,
int fline);
165 #define SWC_LOG_PRINTF(fmt, ...) printf(fmt, __VA_ARGS__)
167 #define SWC_PRINT { try { \
168 ::SWC::Core::MutexSptd::scope \
169 swcdb_logger_lock(::SWC::Core::logger.mutex); \
171 #define SWC_PRINT_CLOSE std::endl; } catch(...) { } }
174 #ifndef SWC_DISABLE_LOG_ALL
178 #define SWC_LOG_OUT(pr, _code_) { \
179 uint8_t _log_pr = pr; \
180 if(::SWC::Core::logger.is_enabled(_log_pr)) { try { \
181 ::SWC::Core::MutexSptd::scope \
182 swcdb_logger_lock(::SWC::Core::logger.mutex); \
183 ::SWC::Core::logger._print_prefix(_log_pr, __FILE__, __LINE__); \
185 SWC_LOG_OSTREAM << std::endl; \
188 #define SWC_LOGF(priority, fmt, ...) \
189 SWC_LOG_OUT(priority, SWC_LOG_PRINTF(fmt, __VA_ARGS__); )
191 #define SWC_LOG(priority, message) \
192 if(::SWC::Core::logger.is_enabled(priority)) { \
193 if(::SWC::Core::logger.show_line_numbers()) \
194 ::SWC::Core::logger.msg(priority, __FILE__, __LINE__, message); \
196 ::SWC::Core::logger.msg(priority, message); \
200 #ifndef SWC_DISABLE_LOG_FATAL
201 #define SWC_LOG_FATAL(msg) do { \
202 SWC_LOG(::SWC::LOG_FATAL, msg); \
205 #define SWC_LOG_FATALF(msg, ...) do { \
206 SWC_LOGF(::SWC::LOG_FATAL, msg, __VA_ARGS__); \
210 #define SWC_LOG_FATAL(msg)
211 #define SWC_LOG_FATALF(msg, ...)
214 #else // SWC_DISABLE_LOGGING
216 #define SWC_LOG(priority, msg)
217 #define SWC_LOGF(priority, fmt, ...)
219 #define SWC_LOG_OUT(pr, code)
221 #define SWC_LOG_FATAL(msg)
222 #define SWC_LOG_FATAL(msg, ...)
224 #endif // SWC_DISABLE_LOGGING
233 #ifdef SWC_IMPL_SOURCE
237 #endif // swcdb_core_Logger_h
constexpr SWC_CAN_INLINE bool is_enabled(uint8_t level) const noexcept
void daemon(const std::string &logs_path)
constexpr SWC_CAN_INLINE const std::string & name() const noexcept
constexpr SWC_CAN_INLINE uint8_t get_level() const noexcept
void initialize(const std::string &name)
constexpr SWC_CAN_INLINE void store(T v) noexcept
Core::Atomic< uint8_t > m_priority
The SWC-DB C++ namespace 'SWC'.
void void SWC_SHOULD_NOT_INLINE void msg(uint8_t priority, const T &msg) noexcept
void _print_prefix(uint8_t priority, const char *filen, int fline)
SWC_SHOULD_NOT_INLINE void msg(uint8_t priority, const char *filen, int fline, const T &msg) noexcept
void log(uint8_t priority, const char *fmt,...) noexcept __attribute__((format(printf
static uint8_t SWC_PURE_FUNC from_string(const std::string &loglevel) noexcept
std::string format(const char *fmt,...) __attribute__((format(printf
constexpr SWC_CAN_INLINE bool show_line_numbers() const noexcept
void _renew_files(time_t secs)
struct SWC::Core::BitFieldInt __attribute__((packed))
void _time_and_level(uint8_t priority)
constexpr SWC_CAN_INLINE void set_level(uint8_t level) noexcept
static std::string repr(uint8_t priority)