sptk2 logo
SPTK Home Page
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
sptk::LogEngine Class Referenceabstract

#include <LogEngine.h>

Inheritance diagram for sptk::LogEngine:
sptk::Thread sptk::FileLogEngine sptk::SysLogEngine

Public Member Functions

virtual void saveMessage (const Logger::UMessage &message)=0
 
 LogEngine (const String &logEngineName)
 
 ~LogEngine () noexcept override
 
virtual void reset ()
 
void options (int ops)
 
size_t options () const
 
void option (int options, bool flag)
 
void priority (LogPriority prt)
 
virtual void minPriority (LogPriority prt)
 
virtual LogPriority minPriority () const
 
- Public Member Functions inherited from sptk::Thread
 Thread (const String &name, const std::shared_ptr< ThreadManager > &threadManager=nullptr)
 
virtual ~Thread ()
 
virtual void run ()
 
bool running () const
 
virtual void threadFunction ()=0
 
virtual void terminate ()
 
virtual void onThreadExit ()
 
virtual bool terminated ()
 
virtual void join ()
 
Id id () const
 
const Stringname () const
 
virtual bool sleep_for (std::chrono::milliseconds interval)
 
virtual bool sleep_until (const DateTime &timestamp)
 

Static Public Member Functions

static String priorityName (LogPriority prt)
 
static LogPriority priorityFromName (const String &prt)
 

Protected Member Functions

void threadFunction () override
 
void log (Logger::UMessage &message)
 
void shutdown () noexcept
 

Friends

class Logger
 

Additional Inherited Members

- Public Types inherited from sptk::Thread
using Id = std::thread::id
 

Detailed Description

Base class for various log engines.

This class is abstract. Derived classes have to implement at least saveMessage() method.

Constructor & Destructor Documentation

◆ LogEngine()

sptk::LogEngine::LogEngine ( const String logEngineName)
explicit

Constructor

Creates a new log object.

◆ ~LogEngine()

sptk::LogEngine::~LogEngine ( )
overridenoexcept

Destructor

Member Function Documentation

◆ log()

void sptk::LogEngine::log ( Logger::UMessage &  message)
protected

Log a message

Parameters
messageMessage

◆ minPriority() [1/2]

virtual LogPriority sptk::LogEngine::minPriority ( ) const
inlinevirtual

Returns the min priority

Messages with priority less than requested are ignored

◆ minPriority() [2/2]

virtual void sptk::LogEngine::minPriority ( LogPriority  prt)
inlinevirtual

Sets min message priority

Messages with priority less than requested are ignored

Parameters
prtLogPriority, min message priority

◆ option()

void sptk::LogEngine::option ( int  options,
bool  flag 
)

Sets an option to true or false

Parameters
optionLog option, one or more of LO_* constants
flagSet option on or off?

◆ options() [1/2]

size_t sptk::LogEngine::options ( ) const
inline

Returns log options

Returns
a bit combination of Option

◆ options() [2/2]

void sptk::LogEngine::options ( int  ops)
inline

Sets log options

Parameters
opsint, a bit combination of Option

◆ priority()

void sptk::LogEngine::priority ( LogPriority  prt)
inline

Sets current message priority

Parameters
prtLogPriority, current message priority

◆ priorityFromName()

static LogPriority sptk::LogEngine::priorityFromName ( const String prt)
static

Priotrity from string representation

◆ priorityName()

static String sptk::LogEngine::priorityName ( LogPriority  prt)
static

String representation of priority

◆ reset()

virtual void sptk::LogEngine::reset ( )
inlinevirtual

Restarts the log

The current log content is cleared. Actual result depends on derived log engine.

Reimplemented in sptk::FileLogEngine.

◆ saveMessage()

virtual void sptk::LogEngine::saveMessage ( const Logger::UMessage &  message)
pure virtual

Stores or sends log message to actual destination

Parameters
messageLog message

Implemented in sptk::FileLogEngine, and sptk::SysLogEngine.

◆ shutdown()

void sptk::LogEngine::shutdown ( )
protectednoexcept

Shutdown log worker thread

References INFO.

◆ threadFunction()

void sptk::LogEngine::threadFunction ( )
overrideprotectedvirtual

The thread function. Should be overwritten by the derived class.

Implements sptk::Thread.


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

Fri Oct 14 2022 09:58:43: SPTK 5.4.1