OSTC Companion  3.0
Companion sofftware for H&W dive computers
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Protected Member Functions | List of all members
Log Class Reference

Basic logging tool. More...

#include <Log.h>

Inheritance diagram for Log:
Inheritance graph
[legend]

Protected Member Functions

 Log (Level level, const char *file, int line, const char *function)
 Constructor. More...
 

Record message and context

enum  Level {
  LEVEL_NOERROR = 0,
  LEVEL_DEBUG,
  LEVEL_TRACE,
  LEVEL_INFO,
  LEVEL_WARNING,
  LEVEL_THROW,
  LEVEL_ERROR
}
 Log level: severity scale. More...
 
const Level level
 Event's log level. More...
 
const QString file
 Source file that fired the log event. More...
 
const int line
 Source line that fired the log event. More...
 
const QString function
 Function (and class) that fired the event. More...
 
QString message
 The log message itself. More...
 

Global services

static Level minLevel = Log::LEVEL_WARNING
 Minimal error level to log. More...
 
static void autoLoad (int argc, char *argv[])
 Initialize the log system, by loading some XML config. More...
 
static void init (int &argc, char *argv[])
 Initialize the log system, without configurations. More...
 
static void close ()
 End the log systems, closing all appenders. More...
 
static QString applicationPath ()
 Utility to retrieve where the executable was installed. More...
 
static QString applicationName ()
 Utility to retrieve the executable's name. More...
 

Detailed Description

Basic logging tool.

Provides easy and centralized log messages for the application. Typical usage:

main(int argc, char* argv[])
{
Log::autoLoad(argc, argv); // Read XML configuration.
LOG_TRACE("... "); // Just a tick where we are.
LOG_INFO("Main started"); // Visible message (users can see it).
LOG_TRACE("Now argc=" << argc);
LOG_TRACE("Invisible message, only for log files");
LOG_DEBUG("Invisible, and logged only if run with a "-d" argument");
}
Note
that message destination can be multiple, and are the responsability of the LogAppender class hierarchy.
See also
LogAppender, LogConsole, LogFile.

Member Enumeration Documentation

enum Log::Level

Log level: severity scale.

Enumerator
LEVEL_NOERROR 
LEVEL_DEBUG 

The most verbose one, used only during debug session.

LEVEL_TRACE 

Messages to be put in silent log files, for post-mortem analysis.

LEVEL_INFO 

General information send to the final user.

LEVEL_WARNING 

Error reported to the user (eg. with a Qt warning box.

See also
LogAppenderWindow).
LEVEL_THROW 

Error that is mean to be catched, and corrected automatically.

LEVEL_ERROR 

Fatal error that cannot be recovered. The program should halt.

Constructor & Destructor Documentation

Log::Log ( Level  level,
const char *  file,
int  line,
const char *  function 
)
protected

Constructor.

All message are to be created by a LogAction instance, responsible to build-up the message, and to send it to LogAppender instances.

Member Function Documentation

QString Log::applicationName ( )
inlinestatic

Utility to retrieve the executable's name.

QString Log::applicationPath ( )
inlinestatic

Utility to retrieve where the executable was installed.

static void Log::autoLoad ( int  argc,
char *  argv[] 
)
static

Initialize the log system, by loading some XML config.

Might be used to change logging configuration of installed applications. Initialize the log system, by loading some XML config.

void Log::close ( )
static

End the log systems, closing all appenders.

void Log::init ( int &  argc,
char *  argv[] 
)
static

Initialize the log system, without configurations.

Then one can instanciate LogAppender classes in a static way.

Member Data Documentation

const QString Log::file

Source file that fired the log event.

const QString Log::function

Function (and class) that fired the event.

const Level Log::level

Event's log level.

const int Log::line

Source line that fired the log event.

QString Log::message

The log message itself.

Log::Level Log::minLevel = Log::LEVEL_WARNING
static

Minimal error level to log.

Defaults to LEVEL_TRACE.


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