eVaf
eVaf::Common::iLogger Class Referenceabstract

Logger interface for eVaf modules and applications. More...

#include <Common/ilogger.h>

Public Types

enum  Severity {
  None = 0, Fatal, Error, Warning,
  Info, Debug, Count
}
 Severity levels for messages indicating the meaning and seriousness of the message. More...
 

Signals

void loggerEvent (Common::iLogger::Severity severity, QString const &text, QString const &source, QString const &where)
 Logger event signal. More...
 

Public Member Functions

virtual Severity consoleSeverity () const =0
 Returns the current console severity level. More...
 
virtual QString defaultSource () const =0
 Returns the current default source name. More...
 
 iLogger ()
 Interface constructor. More...
 
virtual FatalMsgHandler installFatalMsgHandler (FatalMsgHandler newHandler)=0
 Installs a fatal error message handler. More...
 
virtual uint maxCount (QString const &source=0)=0
 Returns the maximum number of log files. More...
 
virtual uint maxSize (QString const &source=0)=0
 Returns the current maximum size of log files in KiB. More...
 
virtual QString printable (QByteArray const &msg) const =0
 Replaces non-printable characters in the input string with human-readable strings. More...
 
virtual QString printf (char const *const fmt,...) const =0
 Helper function for formatting messages using the standard printf() function. More...
 
virtual void setConsoleSeverity (Severity severity)=0
 Changes the console severity level. More...
 
virtual void setDefaultSource (QString const &source)=0
 Sets the default source. More...
 
virtual void setMaxCount (uint maxCount, QString const &source=0)=0
 Changes the maximum number of log files. More...
 
virtual void setMaxSize (uint maxSize, QString const &source=0)=0
 Changes the maximum size of log files for the given source. More...
 
virtual void setSeverity (Severity severity, QString const &source=0)=0
 Changes the current severity level. More...
 
virtual Severity severity (QString const &source=0)=0
 Returns the current severity level. More...
 
virtual void write (Severity severity, QString const &msg, QString const &source=0, QString const &where=0)=0
 Outputs a message. More...
 
virtual ~iLogger ()
 Empty virtual destructor. More...
 

Static Public Member Functions

static iLoggerinstance ()
 Returns the iLogger interface instance. More...
 

Detailed Description

Logger interface for eVaf modules and applications.

#include <Common/iLogger>

Definition at line 50 of file ilogger.h.

Member Enumeration Documentation

Severity levels for messages indicating the meaning and seriousness of the message.

Enumerator
None 

For disabling logging completely (to be not used with messages).

Fatal 

Fatal error that causes the application to stop functioning.

Error 

Unexpected issues in the software that could be solved automatically.

Warning 

Expected issues in the software that will be solved automatically.

Info 

General information output by the application or modules.

Debug 

Information for debugging purposes.

Count 

Number of severity levels.

Definition at line 59 of file ilogger.h.

Constructor & Destructor Documentation

eVaf::Common::iLogger::iLogger ( )
inline

Interface constructor.

Definition at line 70 of file ilogger.h.

virtual eVaf::Common::iLogger::~iLogger ( )
inlinevirtual

Empty virtual destructor.

Definition at line 73 of file ilogger.h.

Member Function Documentation

virtual Severity eVaf::Common::iLogger::consoleSeverity ( ) const
pure virtual

Returns the current console severity level.

Implemented in eVaf::Common::Internal::Logger.

virtual QString eVaf::Common::iLogger::defaultSource ( ) const
pure virtual

Returns the current default source name.

Implemented in eVaf::Common::Internal::Logger.

virtual FatalMsgHandler eVaf::Common::iLogger::installFatalMsgHandler ( FatalMsgHandler  newHandler)
pure virtual

Installs a fatal error message handler.

Parameters
newHandlerThe new fatal error message handler
Returns
The old fatal error message handler

This function installs a custom fatal error message handler. The custom fatal error message handler is responsible for giving feedback to the user and terminating the application.

The default fatal error message handler outputs the message to stderr and terminates the application.

Implemented in eVaf::Common::Internal::Logger.

static iLogger* eVaf::Common::iLogger::instance ( )
static

Returns the iLogger interface instance.

Returns
The iLogger interface

The instance() function returns the global iLogger interface instance. As all the modules and applications are expected to be linked against the Common library, then this is the preferred method of obtaining the iLogger interface. The other method is by using the iRegistry interface.

void eVaf::Common::iLogger::loggerEvent ( Common::iLogger::Severity  severity,
QString const &  text,
QString const &  source,
QString const &  where 
)
signal

Logger event signal.

Parameters
severitySeverity of the message
textThe message
sourceSource of the message
whereWhere the message was output

This signal is emitted for every message output with the iLogger interface. Connect your receiver to this signal if you want to add your own message handling. For example, use this signal to show messages in a log window etc.

virtual uint eVaf::Common::iLogger::maxCount ( QString const &  source = 0)
pure virtual

Returns the maximum number of log files.

Parameters
sourceName of the source or default if omitted.

Implemented in eVaf::Common::Internal::Logger.

virtual uint eVaf::Common::iLogger::maxSize ( QString const &  source = 0)
pure virtual

Returns the current maximum size of log files in KiB.

Parameters
sourceName of the source or default if omitted.

Implemented in eVaf::Common::Internal::Logger.

virtual QString eVaf::Common::iLogger::printable ( QByteArray const &  msg) const
pure virtual

Replaces non-printable characters in the input string with human-readable strings.

Parameters
msgThe input string
Returns
Human-readable string

This function replaces all the non-printable characters with human-readable strings, like ASCII symbol names or HEX codes.

For example, the Line Feed character will be replaced with "[LF]".

Implemented in eVaf::Common::Internal::Logger.

virtual QString eVaf::Common::iLogger::printf ( char const *const  fmt,
  ... 
) const
pure virtual

Helper function for formatting messages using the standard printf() function.

Parameters
fmtThe format string
...Variable number of arguments
Returns
The formatted string

Implemented in eVaf::Common::Internal::Logger.

virtual void eVaf::Common::iLogger::setConsoleSeverity ( Severity  severity)
pure virtual

Changes the console severity level.

Parameters
severityThe new console severity level

This function changes the console severity level. By default, only fatal errors are output to the console.

Implemented in eVaf::Common::Internal::Logger.

virtual void eVaf::Common::iLogger::setDefaultSource ( QString const &  source)
pure virtual

Sets the default source.

Parameters
sourceThe new default source name.

Use the setDefaultSource() function to change the default source name. If not set, then uses the default source name "common".

Changing the name of the default source resets any other settings set for the default source.

Implemented in eVaf::Common::Internal::Logger.

virtual void eVaf::Common::iLogger::setMaxCount ( uint  maxCount,
QString const &  source = 0 
)
pure virtual

Changes the maximum number of log files.

Parameters
maxCountThe new maximum number
sourceName of the source or default if omitted

This function sets the maximum number of log files including the current log file and any backup files. Older backup files are deleted to keep the number of log files at the maximum.

The default value for all the sources is usually 3 (the current log file plus 2 backup files).

Set the maximum number of log files to 0 for no limits (dangerous!).

Implemented in eVaf::Common::Internal::Logger.

virtual void eVaf::Common::iLogger::setMaxSize ( uint  maxSize,
QString const &  source = 0 
)
pure virtual

Changes the maximum size of log files for the given source.

Parameters
maxSizeThe new maximum size in KiB
sourceName of the source of default if omitted.

This function changes the maximum size of log files. Log files larger than this value will be renamed to backup files.

The default value for all the sources is usually 100 KiB.

Set the maximum size to 0 for no limits (dangerous!).

Implemented in eVaf::Common::Internal::Logger.

virtual void eVaf::Common::iLogger::setSeverity ( Severity  severity,
QString const &  source = 0 
)
pure virtual

Changes the current severity level.

Parameters
severityThe new severity level
sourceName of the source or default if omitted.

This function changes the severity level of the given logger source. By default, only fatal errors are output. With this function the severity level can be changed so that also less important messages are output.

Implemented in eVaf::Common::Internal::Logger.

virtual Severity eVaf::Common::iLogger::severity ( QString const &  source = 0)
pure virtual

Returns the current severity level.

Parameters
sourceName of the source or default if omitted.

Implemented in eVaf::Common::Internal::Logger.

virtual void eVaf::Common::iLogger::write ( Severity  severity,
QString const &  msg,
QString const &  source = 0,
QString const &  where = 0 
)
pure virtual

Outputs a message.

Parameters
severitySeverity of the message, ie how important it is.
msgThe message to be output
sourceSource of the message or default if omitted.
whereLocation in the source file where the message was output.

This function writes a message to the log file if the severity is high enough. If the severity is lower than the current severity level, then does nothing.

If the source parameter is given, then uses the specified source. Otherwise writes to the default log file.

The where parameter can be used to indicate the location in the source file where the message was generated.

Messages for the default source are also output to the console if the console severity level is high enough.

Implemented in eVaf::Common::Internal::Logger.


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