Deskflow 1.22.0.197
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
Log Class Reference

Logging facility. More...

#include <Log.h>

Public Member Functions

 Log (bool singleton=true)
 Log (Log *src)
 Log (Log const &)=delete
 Log (Log &&)=delete
 ~Log ()
Logoperator= (Log const &)=delete
Logoperator= (Log &&)=delete
manipulators
void insert (ILogOutputter *adoptedOutputter, bool alwaysAtHead=false)
 Add an outputter to the head of the list and adopts it.
void remove (ILogOutputter *orphaned)
 Remove an outputter from the list.
void pop_front (bool alwaysAtHead=false)
 Remove the outputter from the head of the list.
bool setFilter (const char *name)
 Set the minimum priority filter.
void setFilter (LogLevel)
 Set the minimum priority filter (by ordinal).

accessors

void print (const char *file, int line, const char *format,...)
 Print a log message.
LogLevel getFilter () const
 Get the minimum priority level.
const char * getFilterName () const
 Get the filter name of the current filter level.
const char * getFilterName (LogLevel level) const
 Get the filter name of a specified filter level.
LogLevel getConsoleMaxLevel () const
static LoggetInstance ()
 Get the singleton instance of the log.

Detailed Description

Logging facility.

The logging class; all console output should go through this class. It supports multithread safe operation, several message priority levels, filtering by priority, and output redirection. The macros LOG() and LOGC() provide convenient access.

Constructor & Destructor Documentation

◆ Log() [1/4]

Log::Log ( bool singleton = true)
explicit

◆ Log() [2/4]

Log::Log ( Log * src)
explicit

◆ Log() [3/4]

Log::Log ( Log const & )
delete

◆ Log() [4/4]

Log::Log ( Log && )
delete

◆ ~Log()

Log::~Log ( )

Member Function Documentation

◆ getConsoleMaxLevel()

LogLevel Log::getConsoleMaxLevel ( ) const
inline

Get the console filter level (messages above this are not sent to console).

◆ getFilter()

LogLevel Log::getFilter ( ) const

Get the minimum priority level.

◆ getFilterName() [1/2]

const char * Log::getFilterName ( ) const

Get the filter name of the current filter level.

◆ getFilterName() [2/2]

const char * Log::getFilterName ( LogLevel level) const

Get the filter name of a specified filter level.

◆ getInstance()

Log * Log::getInstance ( )
static

Get the singleton instance of the log.

◆ insert()

void Log::insert ( ILogOutputter * adoptedOutputter,
bool alwaysAtHead = false )

Add an outputter to the head of the list and adopts it.

Inserts an outputter to the head of the outputter list. The outputter is deleted when Log destructor is called.

When the logger writes a message, it goes to the outputter at the head of the outputter list. If that outputter's write() method returns true then it also goes to the next outputter, as so on until an outputter returns false or there are no more outputters. Outputters still in the outputter list when the log is destroyed will be deleted. If alwaysAtHead is true then the outputter is always called before all outputters with alwaysAtHead false and the return value of the outputter is ignored.

By default, the logger has one outputter installed which writes to the console.

◆ operator=() [1/2]

Log & Log::operator= ( Log && )
delete

◆ operator=() [2/2]

Log & Log::operator= ( Log const & )
delete

◆ pop_front()

void Log::pop_front ( bool alwaysAtHead = false)

Remove the outputter from the head of the list.

Removes and deletes the outputter at the head of the outputter list. This does nothing if the outputter list is empty. Only removes outputters that were inserted with the matching alwaysAtHead.

◆ print()

void Log::print ( const char * file,
int line,
const char * format,
... )

Print a log message.

Print a log message using the printf-like format and arguments preceded by the filename and line number. If file is nullptr then neither the file nor the line are printed.

◆ remove()

void Log::remove ( ILogOutputter * orphaned)

Remove an outputter from the list.

Removes the first occurrence of the given outputter from the outputter list. It does nothing if the outputter is not in the list. The outputter is not deleted.

◆ setFilter() [1/2]

bool Log::setFilter ( const char * name)

Set the minimum priority filter.

Set the filter. Messages below this priority are discarded. The default priority is 4 (INFO) (unless built without NDEBUG in which case it's 5 (DEBUG)). setFilter(const char*) returns true if the priority name was recognized; if name is nullptr then it simply returns true.

◆ setFilter() [2/2]

void Log::setFilter ( LogLevel maxPriority)

Set the minimum priority filter (by ordinal).


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