SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
SWC::Core::LogWriter Class Referencefinal

#include <swcdb/core/Logger.h>

+ Collaboration diagram for SWC::Core::LogWriter:

Public Member Functions

 LogWriter () noexcept
 
 LogWriter (LogWriter &&)=delete
 
 LogWriter (const LogWriter &)=delete
 
LogWriteroperator= (const LogWriter &)=delete
 
LogWriteroperator= (LogWriter &&)=delete
 
 ~LogWriter () noexcept
 
void initialize (const std::string &name)
 
void daemon (const std::string &logs_path)
 
constexpr SWC_CAN_INLINE const std::string & name () const noexcept
 
constexpr SWC_CAN_INLINE void set_level (uint8_t level) noexcept
 
constexpr SWC_CAN_INLINE uint8_t get_level () const noexcept
 
constexpr SWC_CAN_INLINE bool is_enabled (uint8_t level) const noexcept
 
constexpr SWC_CAN_INLINE bool show_line_numbers () const noexcept
 
void log (uint8_t priority, const char *fmt,...) noexcept __attribute__((format(printf
 
void void log (uint8_t priority, const char *filen, int fline, const char *fmt,...) noexcept __attribute__((format(printf
 
template<typename T >
void void SWC_SHOULD_NOT_INLINE void msg (uint8_t priority, const T &msg) noexcept
 
template<typename T >
SWC_SHOULD_NOT_INLINE void msg (uint8_t priority, const char *filen, int fline, const T &msg) noexcept
 
void _print_prefix (uint8_t priority, const char *filen, int fline)
 

Static Public Member Functions

static std::string repr (uint8_t priority)
 
static uint8_t SWC_PURE_FUNC from_string (const std::string &loglevel) noexcept
 

Public Attributes

MutexSptd mutex
 

Private Member Functions

void _time_and_level (uint8_t priority)
 
void _renew_files (time_t secs)
 

Private Attributes

std::string m_name
 
std::string m_logs_path
 
FILE * m_file_out
 
Core::Atomic< uint8_t > m_priority
 
bool m_show_line_numbers
 
bool m_daemon
 
time_t m_next_time
 

Detailed Description

Definition at line 50 of file Logger.h.

Constructor & Destructor Documentation

◆ LogWriter() [1/3]

SWC_SHOULD_NOT_INLINE SWC::Core::LogWriter::LogWriter ( )
noexcept

Definition at line 65 of file Logger.cc.

◆ LogWriter() [2/3]

SWC::Core::LogWriter::LogWriter ( LogWriter &&  )
delete

◆ LogWriter() [3/3]

SWC::Core::LogWriter::LogWriter ( const LogWriter )
delete

◆ ~LogWriter()

SWC::Core::LogWriter::~LogWriter ( )
noexcept

Definition at line 71 of file Logger.cc.

Member Function Documentation

◆ _print_prefix()

SWC_SHOULD_NOT_INLINE void SWC::Core::LogWriter::_print_prefix ( uint8_t  priority,
const char *  filen,
int  fline 
)

Definition at line 195 of file Logger.cc.

References _time_and_level(), show_line_numbers(), and SWC_LOG_OSTREAM.

Referenced by msg().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _renew_files()

void SWC::Core::LogWriter::_renew_files ( time_t  secs)
private

Definition at line 117 of file Logger.cc.

References SWC::Common::Files::Schema::filepath(), m_file_out, m_logs_path, m_name, m_next_time, SWC_LOG_OSTREAM, SWC_MKDIR, and SWC::Core::to_string().

Referenced by _time_and_level(), and daemon().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _time_and_level()

SWC_SHOULD_NOT_INLINE void SWC::Core::LogWriter::_time_and_level ( uint8_t  priority)
private

Definition at line 101 of file Logger.cc.

References _renew_files(), m_daemon, m_next_time, and SWC_LOG_OSTREAM.

Referenced by _print_prefix(), log(), and msg().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ daemon()

SWC_SHOULD_NOT_INLINE void SWC::Core::LogWriter::daemon ( const std::string &  logs_path)

Definition at line 80 of file Logger.cc.

References _renew_files(), SWC::Error::get_text(), m_daemon, m_logs_path, mutex, and SWC::Core::to_string().

Referenced by SWC::Config::Settings::init_process().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ from_string()

uint8_t SWC::Core::LogWriter::from_string ( const std::string &  loglevel)
staticnoexcept

Definition at line 44 of file Logger.cc.

References SWC::LOG_ALERT, SWC::LOG_CRIT, SWC::LOG_DEBUG, SWC::LOG_ERROR, SWC::LOG_FATAL, SWC::LOG_INFO, SWC::LOG_NOTICE, SWC::LOG_WARN, and SWC::Condition::str_case_eq().

Referenced by SWC::Config::Settings::init_options().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_level()

constexpr SWC_CAN_INLINE uint8_t SWC::Core::LogWriter::get_level ( ) const
inlineconstexprnoexcept

Definition at line 90 of file Logger.h.

References m_priority.

◆ initialize()

SWC_SHOULD_NOT_INLINE void SWC::Core::LogWriter::initialize ( const std::string &  name)

Definition at line 74 of file Logger.cc.

References m_name, mutex, and name().

Referenced by SWC::Config::Settings::init_process().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_enabled()

constexpr SWC_CAN_INLINE bool SWC::Core::LogWriter::is_enabled ( uint8_t  level) const
inlineconstexprnoexcept

Definition at line 95 of file Logger.h.

References m_priority.

◆ log() [1/2]

SWC_SHOULD_NOT_INLINE void SWC::Core::LogWriter::log ( uint8_t  priority,
const char *  filen,
int  fline,
const char *  fmt,
  ... 
)
noexcept

Definition at line 177 of file Logger.cc.

References _time_and_level(), mutex, show_line_numbers(), and SWC_LOG_OSTREAM.

+ Here is the call graph for this function:

◆ log() [2/2]

SWC_SHOULD_NOT_INLINE void SWC::Core::LogWriter::log ( uint8_t  priority,
const char *  fmt,
  ... 
)
noexcept

Definition at line 162 of file Logger.cc.

References _time_and_level(), mutex, and SWC_LOG_OSTREAM.

+ Here is the call graph for this function:

◆ msg() [1/2]

template<typename T >
SWC_SHOULD_NOT_INLINE void SWC::Core::LogWriter::msg ( uint8_t  priority,
const char *  filen,
int  fline,
const T &  msg 
)
inlinenoexcept

Definition at line 123 of file Logger.h.

References _print_prefix(), msg(), mutex, and SWC_LOG_OSTREAM.

+ Here is the call graph for this function:

◆ msg() [2/2]

template<typename T >
void void SWC_SHOULD_NOT_INLINE void SWC::Core::LogWriter::msg ( uint8_t  priority,
const T &  msg 
)
inlinenoexcept

Definition at line 113 of file Logger.h.

References _time_and_level(), mutex, and SWC_LOG_OSTREAM.

Referenced by msg().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ name()

constexpr SWC_CAN_INLINE const std::string& SWC::Core::LogWriter::name ( ) const
inlineconstexprnoexcept

Definition at line 80 of file Logger.h.

References m_name.

Referenced by initialize().

+ Here is the caller graph for this function:

◆ operator=() [1/2]

LogWriter& SWC::Core::LogWriter::operator= ( const LogWriter )
delete

◆ operator=() [2/2]

LogWriter& SWC::Core::LogWriter::operator= ( LogWriter &&  )
delete

◆ repr()

std::string SWC::Core::LogWriter::repr ( uint8_t  priority)
static

Definition at line 38 of file Logger.cc.

References SWC::LOG_DEBUG, and SWC::Core::to_string().

Referenced by SWC::Config::Settings::init_options().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_level()

constexpr SWC_CAN_INLINE void SWC::Core::LogWriter::set_level ( uint8_t  level)
inlineconstexprnoexcept

Definition at line 85 of file Logger.h.

References m_priority, and SWC::Core::AtomicBase< T, OrderT >::store().

Referenced by SWC::Config::Settings::init_options().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ show_line_numbers()

constexpr SWC_CAN_INLINE bool SWC::Core::LogWriter::show_line_numbers ( ) const
inlineconstexprnoexcept

Definition at line 100 of file Logger.h.

References m_show_line_numbers.

Referenced by _print_prefix(), and log().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_daemon

bool SWC::Core::LogWriter::m_daemon
private

Definition at line 147 of file Logger.h.

Referenced by _time_and_level(), and daemon().

◆ m_file_out

FILE* SWC::Core::LogWriter::m_file_out
private

Definition at line 143 of file Logger.h.

Referenced by _renew_files().

◆ m_logs_path

std::string SWC::Core::LogWriter::m_logs_path
private

Definition at line 142 of file Logger.h.

Referenced by _renew_files(), and daemon().

◆ m_name

std::string SWC::Core::LogWriter::m_name
private

Definition at line 141 of file Logger.h.

Referenced by _renew_files(), initialize(), and name().

◆ m_next_time

time_t SWC::Core::LogWriter::m_next_time
private

Definition at line 148 of file Logger.h.

Referenced by _renew_files(), and _time_and_level().

◆ m_priority

Core::Atomic<uint8_t> SWC::Core::LogWriter::m_priority
private

Definition at line 145 of file Logger.h.

Referenced by get_level(), is_enabled(), and set_level().

◆ m_show_line_numbers

bool SWC::Core::LogWriter::m_show_line_numbers
private

Definition at line 146 of file Logger.h.

Referenced by show_line_numbers().

◆ mutex

MutexSptd SWC::Core::LogWriter::mutex

Definition at line 59 of file Logger.h.

Referenced by daemon(), initialize(), log(), and msg().


The documentation for this class was generated from the following files: