eVaf
eVaf::Common::Internal::Logger Class Reference

iLogger interface implementation. More...

#include <Common/logger.h>

Signals

void writeToLogFile (LoggerSource const &src, QString const &msg)
 
- Signals inherited from eVaf::Common::iLogger
void loggerEvent (Common::iLogger::Severity severity, QString const &text, QString const &source, QString const &where)
 Logger event signal. More...
 

Public Member Functions

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

Additional Inherited Members

- Public Types inherited from eVaf::Common::iLogger
enum  Severity {
  None = 0, Fatal, Error, Warning,
  Info, Debug, Count
}
 Severity levels for messages indicating the meaning and seriousness of the message. More...
 
- Static Public Member Functions inherited from eVaf::Common::iLogger
static iLoggerinstance ()
 Returns the iLogger interface instance. More...
 

Detailed Description

iLogger interface implementation.

This class implements the iLogger interface.

Definition at line 135 of file logger.h.

Constructor & Destructor Documentation

eVaf::Common::Internal::Logger::Logger ( )
virtual eVaf::Common::Internal::Logger::~Logger ( )
virtual

Member Function Documentation

virtual iLogger::Severity eVaf::Common::Internal::Logger::consoleSeverity ( ) const
inlinevirtual

Returns the current console severity level.

Implements eVaf::Common::iLogger.

Definition at line 171 of file logger.h.

virtual QString eVaf::Common::Internal::Logger::defaultSource ( ) const
virtual

Returns the current default source name.

Implements eVaf::Common::iLogger.

bool eVaf::Common::Internal::Logger::init ( )

Initializes the iLogger interface implementation.

Returns
True if ok; false if initialization failed
virtual FatalMsgHandler eVaf::Common::Internal::Logger::installFatalMsgHandler ( FatalMsgHandler  newHandler)
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.

Implements eVaf::Common::iLogger.

virtual uint eVaf::Common::Internal::Logger::maxCount ( QString const &  source = 0)
virtual

Returns the maximum number of log files.

Parameters
sourceName of the source or default if omitted.

Implements eVaf::Common::iLogger.

virtual uint eVaf::Common::Internal::Logger::maxSize ( QString const &  source = 0)
virtual

Returns the current maximum size of log files in KiB.

Parameters
sourceName of the source or default if omitted.

Implements eVaf::Common::iLogger.

virtual QString eVaf::Common::Internal::Logger::printable ( QByteArray const &  msg) const
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]".

Implements eVaf::Common::iLogger.

virtual QString eVaf::Common::Internal::Logger::printf ( char const *const  fmt,
  ... 
) const
virtual

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

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

Implements eVaf::Common::iLogger.

virtual void eVaf::Common::Internal::Logger::setConsoleSeverity ( iLogger::Severity  severity)
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.

Implements eVaf::Common::iLogger.

virtual void eVaf::Common::Internal::Logger::setDefaultSource ( QString const &  source)
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.

Implements eVaf::Common::iLogger.

virtual void eVaf::Common::Internal::Logger::setMaxCount ( uint  maxCount,
QString const &  source = 0 
)
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!).

Implements eVaf::Common::iLogger.

virtual void eVaf::Common::Internal::Logger::setMaxSize ( uint  maxSize,
QString const &  source = 0 
)
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!).

Implements eVaf::Common::iLogger.

virtual void eVaf::Common::Internal::Logger::setSeverity ( iLogger::Severity  severity,
QString const &  source = 0 
)
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.

Implements eVaf::Common::iLogger.

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

Returns the current severity level.

Parameters
sourceName of the source or default if omitted.

Implements eVaf::Common::iLogger.

virtual void eVaf::Common::Internal::Logger::write ( Severity  severity,
QString const &  msg,
QString const &  source = 0,
QString const &  where = 0 
)
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.

Implements eVaf::Common::iLogger.

void eVaf::Common::Internal::Logger::writeToLogFile ( LoggerSource const &  src,
QString const &  msg 
)
signal

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