mirror of https://github.com/Icinga/icinga2.git
Added documentation for the logger classes.
This commit is contained in:
parent
7d859e2e18
commit
f2979eb08b
|
@ -2,10 +2,20 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
/**
|
||||
* Constructor for the ConsoleLogger class.
|
||||
*
|
||||
* @param minSeverity Minimum severity for log messages.
|
||||
*/
|
||||
ConsoleLogger::ConsoleLogger(LogSeverity minSeverity)
|
||||
: Logger(minSeverity)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Processes a log entry and outputs it to standard out.
|
||||
*
|
||||
* @param entry The log entry.
|
||||
*/
|
||||
void ConsoleLogger::ProcessLogEntry(const LogEntry& entry)
|
||||
{
|
||||
char timestamp[100];
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
namespace icinga
|
||||
{
|
||||
|
||||
/**
|
||||
* A logger that logs to stderr.
|
||||
*/
|
||||
class ConsoleLogger : public Logger
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -23,6 +23,12 @@ using namespace icinga;
|
|||
|
||||
vector<Logger::Ptr> Logger::m_Loggers;
|
||||
|
||||
/**
|
||||
* Constructor for the logger class.
|
||||
*
|
||||
* @param minSeverity The minimum severity of log messages that should be sent
|
||||
* to this logger.
|
||||
*/
|
||||
Logger::Logger(LogSeverity minSeverity)
|
||||
: m_MinSeverity(minSeverity)
|
||||
{ }
|
||||
|
@ -48,16 +54,31 @@ void Logger::Write(LogSeverity severity, const string& facility,
|
|||
Event::Post(ev);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new logger.
|
||||
*
|
||||
* @param logger The logger.
|
||||
*/
|
||||
void Logger::RegisterLogger(const Logger::Ptr& logger)
|
||||
{
|
||||
m_Loggers.push_back(logger);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the minimum severity for this logger.
|
||||
*
|
||||
* @returns The minimum severity.
|
||||
*/
|
||||
LogSeverity Logger::GetMinSeverity(void) const
|
||||
{
|
||||
return m_MinSeverity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forwards a log entry to the registered loggers.
|
||||
*
|
||||
* @param entry The log entry.
|
||||
*/
|
||||
void Logger::ForwardLogEntry(const LogEntry& entry)
|
||||
{
|
||||
vector<Logger::Ptr>::iterator it;
|
||||
|
|
|
@ -36,6 +36,11 @@ enum LogSeverity
|
|||
LogCritical
|
||||
};
|
||||
|
||||
/**
|
||||
* A lot entry.
|
||||
*
|
||||
* @ingroup base
|
||||
*/
|
||||
struct LogEntry {
|
||||
time_t Timestamp;
|
||||
LogSeverity Severity;
|
||||
|
@ -43,6 +48,9 @@ struct LogEntry {
|
|||
string Message;
|
||||
};
|
||||
|
||||
/**
|
||||
* Base class for all loggers.
|
||||
*/
|
||||
class I2_BASE_API Logger : public Object
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue