Logger.
More...
#include <Logger.hpp>
|
|
| Logger () |
| | Constructs logger with enabled log level set to warning.
|
| |
|
| ~Logger () |
| | Default destructor.
|
| |
| void | setEnabled (bool state, LogStream::Level level=LogStream::Level::Warning) |
| | Enables/disables given level. More...
|
| |
| bool | isEnabled (LogStream::Level level) const |
| | Checks if given level is enabled. More...
|
| |
| void | setOutputConsole (bool state) |
| | Adds/deletes console output sink to/from logger sinks. More...
|
| |
| void | setOutputFile (bool state, const std::string &filepath=std::string(), bool append=true) |
| | Adds/deletes file output sink to/from logger sinks. More...
|
| |
| void | setOutputSyslog (bool state, const std::string &ident=std::string()) |
| | Adds/deletes syslog output sink to/from logger sinks. More...
|
| |
| void | setAuditFile (bool state, const std::string &filepath) |
| | Adds/deletes audit file output sink to/from logger sinks. More...
|
| |
| void | addOutputSink (std::unique_ptr< LogSink > &sink) |
| | Adds given sink into logger output sinks. More...
|
| |
| void | delOutputSink (const std::string &name) |
| | Deletes given sink from logger output sinks. More...
|
| |
| LogStream | operator() (const std::string &file, int line, const std::string &function, LogStream::Level level) |
| | Constructs and returns new LogStream object initialized with this logger, source containing given file, line and function, and given level. More...
|
| |
| void | write (const LogStream::Source &source, LogStream::Level level, const std::string &message) |
| | Writes information into all sinks. More...
|
| |
◆ addOutputSink()
| void usbguard::Logger::addOutputSink |
( |
std::unique_ptr< LogSink > & |
sink | ) |
|
Adds given sink into logger output sinks.
- Parameters
-
◆ delOutputSink()
| void usbguard::Logger::delOutputSink |
( |
const std::string & |
name | ) |
|
Deletes given sink from logger output sinks.
- Parameters
-
| name | Name of output sink to delete. |
◆ isEnabled()
Checks if given level is enabled.
Internally checks whether current_level >= given_level.
- Parameters
-
- Returns
- True if given level is enabled, false otherwise.
◆ operator()()
| LogStream usbguard::Logger::operator() |
( |
const std::string & |
file, |
|
|
int |
line, |
|
|
const std::string & |
function, |
|
|
LogStream::Level |
level |
|
) |
| |
Constructs and returns new LogStream object initialized with this logger, source containing given file, line and function, and given level.
- Parameters
-
| file | File name. |
| line | Line number. |
| function | Name of the function. |
| level | Log level. |
- Returns
- New LogStream object.
◆ setAuditFile()
| void usbguard::Logger::setAuditFile |
( |
bool |
state, |
|
|
const std::string & |
filepath |
|
) |
| |
Adds/deletes audit file output sink to/from logger sinks.
- Parameters
-
| state | If true, then audit file output sink is added to logger output sinks, otherwise it is deleted from sinks. |
◆ setEnabled()
| void usbguard::Logger::setEnabled |
( |
bool |
state, |
|
|
LogStream::Level |
level = LogStream::Level::Warning |
|
) |
| |
Enables/disables given level.
- Note
- Default level is warning.
- Parameters
-
| state | Determines if given level should be enabled/disabled. |
| level | Log level to enable/disable. |
◆ setOutputConsole()
| void usbguard::Logger::setOutputConsole |
( |
bool |
state | ) |
|
Adds/deletes console output sink to/from logger sinks.
- Parameters
-
| state | If true, then console output sink is added to logger output sinks, otherwise it is deleted from sinks. |
◆ setOutputFile()
| void usbguard::Logger::setOutputFile |
( |
bool |
state, |
|
|
const std::string & |
filepath = std::string(), |
|
|
bool |
append = true |
|
) |
| |
Adds/deletes file output sink to/from logger sinks.
- Parameters
-
| state | If true, then file output sink is added to logger output sinks, otherwise it is deleted from sinks. |
| append | Opens file output sink in append mode. |
◆ setOutputSyslog()
| void usbguard::Logger::setOutputSyslog |
( |
bool |
state, |
|
|
const std::string & |
ident = std::string() |
|
) |
| |
Adds/deletes syslog output sink to/from logger sinks.
- Parameters
-
| state | If true, then syslog output sink is added to logger output sinks, otherwise it is deleted from sinks. |
◆ timestamp()
| const std::string usbguard::Logger::timestamp |
( |
| ) |
|
|
static |
Generate a timestamp string.
Format: <seconds>.<microseconds>
- Returns
- Timestamp string.
◆ write()
Writes information into all sinks.
- Parameters
-
The documentation for this class was generated from the following files: