Lunchbox  1.10.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
log.h File Reference

This file contains logging classes. More...

#include <lunchbox/api.h>
#include <lunchbox/compiler.h>
#include <lunchbox/types.h>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <sstream>
+ Include dependency graph for log.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  lunchbox::Log
 The logging class. More...
 

Namespaces

 lunchbox
 Abstraction layer and common utilities for multi-threaded programming.
 

Macros

#define LBERROR
 Output an error message to the per-thread Log stream. More...
 
#define LBWARN
 Output a warning message to the per-thread Log stream. More...
 
#define LBINFO
 Output an informational message to the per-thread Log. More...
 
#define LBVERB
 Output a verbatim message to the per-thread Log stream. More...
 
#define LBLOG(topic)
 Output a message pertaining to a topic to the per-thread Log stream. More...
 
#define LBTHROW(exc)
 Log a std::exception if topic LOG_EXCEPTION is set before throwing exception. More...
 

Enumerations

enum  lunchbox::LogLevel {
  lunchbox::LOG_ERROR = 1, lunchbox::LOG_WARN, lunchbox::LOG_INFO, lunchbox::LOG_VERB,
  LOG_ALL
}
 The logging levels. More...
 
enum  lunchbox::LogTopic { lunchbox::LOG_EXCEPTION = 0x01, lunchbox::LOG_PLUGIN = 0x02, lunchbox::LOG_CUSTOM = 0x10, lunchbox::LOG_ANY = 0xffffu }
 The logging topics. More...
 

Functions

LUNCHBOX_API std::ostream & lunchbox::indent (std::ostream &os)
 Increases the indentation level of the Log stream, causing subsequent lines to be intended by four characters. More...
 
LUNCHBOX_API std::ostream & lunchbox::exdent (std::ostream &os)
 Decrease the indentation level of the Log stream. More...
 
LUNCHBOX_API std::ostream & lunchbox::disableFlush (std::ostream &os)
 Disable flushing of the Log stream. More...
 
LUNCHBOX_API std::ostream & lunchbox::enableFlush (std::ostream &os)
 Re-enable flushing of the Log stream. More...
 
LUNCHBOX_API std::ostream & lunchbox::forceFlush (std::ostream &os)
 Flush the Log stream regardless of the auto-flush state. More...
 
LUNCHBOX_API std::ostream & lunchbox::disableHeader (std::ostream &os)
 Disable printing of the Log header for subsequent lines. More...
 
LUNCHBOX_API std::ostream & lunchbox::enableHeader (std::ostream &os)
 Re-enable printing of the Log header. More...
 
std::ostream & lunchbox::startBlock (std::ostream &os)
 Indent, disable flush and header for block printing. More...
 
std::ostream & lunchbox::stopBlock (std::ostream &os)
 Exdent, denable flush and header to stop block print. More...
 

Detailed Description

This file contains logging classes.

The macros LBERROR, LBWARN, LBINFO and LBVERB output messages at their respective logging level, if the level is active. They use a per-thread lunchbox::Log instance, which is a std::ostream. LBVERB is always inactive in release builds.

Definition in file log.h.

Macro Definition Documentation

#define LBERROR
Value:
lunchbox::Log::instance( __FILE__, __LINE__ )
Output critical errors.
Definition: log.h:45
static LUNCHBOX_API Log & instance()
The per-thread logger.
static LUNCHBOX_API int level
The current log level.
Definition: log.h:99

Output an error message to the per-thread Log stream.

Version
1.0

Definition at line 191 of file log.h.

#define LBINFO
Value:
lunchbox::Log::instance( __FILE__, __LINE__ )
Output informational messages.
Definition: log.h:47
static LUNCHBOX_API Log & instance()
The per-thread logger.
static LUNCHBOX_API int level
The current log level.
Definition: log.h:99

Output an informational message to the per-thread Log.

Version
1.0

Definition at line 197 of file log.h.

#define LBLOG (   topic)
Value:
(lunchbox::Log::topics & (topic)) && \
lunchbox::Log::instance( __FILE__, __LINE__ )
static LUNCHBOX_API Log & instance()
The per-thread logger.
static LUNCHBOX_API unsigned topics
The current log topics.
Definition: log.h:102

Output a message pertaining to a topic to the per-thread Log stream.

Version
1.0

Definition at line 213 of file log.h.

#define LBTHROW (   exc)
Value:
{ \
LBINFO << exc.what() << std::endl; \
throw exc; \
}
#define LBINFO
Output an informational message to the per-thread Log.
Definition: log.h:197

Log a std::exception if topic LOG_EXCEPTION is set before throwing exception.

Version
1.7.1

Definition at line 220 of file log.h.

#define LBVERB
Value:
lunchbox::Log::instance( __FILE__, __LINE__ )
Be noisy.
Definition: log.h:48
static LUNCHBOX_API Log & instance()
The per-thread logger.
static LUNCHBOX_API int level
The current log level.
Definition: log.h:99

Output a verbatim message to the per-thread Log stream.

Version
1.0

Definition at line 205 of file log.h.

#define LBWARN
Value:
lunchbox::Log::instance( __FILE__, __LINE__ )
static LUNCHBOX_API Log & instance()
The per-thread logger.
static LUNCHBOX_API int level
The current log level.
Definition: log.h:99
Output potentially critical warnings.
Definition: log.h:46

Output a warning message to the per-thread Log stream.

Version
1.0

Definition at line 194 of file log.h.

Referenced by lunchbox::daemonize().