 |
SWC-DB
v0.5.11 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);
62 LogWriter(
const std::string& name=
"",
const std::string& logs_path=
"");
68 void daemon(const std::
string& logs_path);
90 void log(uint8_t priority,
const char* fmt, ...)
93 void log(uint8_t priority, const
char* filen,
int fline,
99 void msg(uint8_t priority, const
T&
msg) noexcept {
108 SWC_SHOULD_NOT_INLINE
109 void msg(uint8_t priority,
const char* filen,
int fline,
110 const T&
msg) noexcept {
118 void _print_prefix(uint8_t priority,
const char* filen,
int fline);
151 #define SWC_LOG_PRINTF(fmt, ...) printf(fmt, __VA_ARGS__)
153 #define SWC_PRINT { try { \
154 ::SWC::Core::MutexSptd::scope \
155 swcdb_logger_lock(::SWC::Core::logger.mutex); \
157 #define SWC_PRINT_CLOSE std::endl; } catch(...) { } }
160 #ifndef SWC_DISABLE_LOG_ALL
164 #define SWC_LOG_OUT(pr, _code_) { \
165 uint8_t _log_pr = pr; \
166 if(::SWC::Core::logger.is_enabled(_log_pr)) { try { \
167 ::SWC::Core::MutexSptd::scope \
168 swcdb_logger_lock(::SWC::Core::logger.mutex); \
169 ::SWC::Core::logger._print_prefix(_log_pr, __FILE__, __LINE__); \
171 SWC_LOG_OSTREAM << std::endl; \
174 #define SWC_LOGF(priority, fmt, ...) \
175 SWC_LOG_OUT(priority, SWC_LOG_PRINTF(fmt, __VA_ARGS__); )
177 #define SWC_LOG(priority, message) \
178 if(::SWC::Core::logger.is_enabled(priority)) { \
179 if(::SWC::Core::logger.show_line_numbers()) \
180 ::SWC::Core::logger.msg(priority, __FILE__, __LINE__, message); \
182 ::SWC::Core::logger.msg(priority, message); \
186 #ifndef SWC_DISABLE_LOG_FATAL
187 #define SWC_LOG_FATAL(msg) do { \
188 SWC_LOG(::SWC::LOG_FATAL, msg); \
191 #define SWC_LOG_FATALF(msg, ...) do { \
192 SWC_LOGF(::SWC::LOG_FATAL, msg, __VA_ARGS__); \
196 #define SWC_LOG_FATAL(msg)
197 #define SWC_LOG_FATALF(msg, ...)
200 #else // SWC_DISABLE_LOGGING
202 #define SWC_LOG(priority, msg)
203 #define SWC_LOGF(priority, fmt, ...)
205 #define SWC_LOG_OUT(pr, code)
207 #define SWC_LOG_FATAL(msg)
208 #define SWC_LOG_FATAL(msg, ...)
210 #endif // SWC_DISABLE_LOGGING
219 #ifdef SWC_IMPL_SOURCE
223 #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 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)
LogWriter(const std::string &name="", const std::string &logs_path="")
constexpr SWC_CAN_INLINE void set_level(uint8_t level) noexcept
static std::string repr(uint8_t priority)