27 #ifndef LUNCHBOX_LOG_H
28 #define LUNCHBOX_LOG_H
31 #include <lunchbox/compiler.h>
62 namespace detail {
class Log; }
70 class Log :
public std::ostream
74 LUNCHBOX_API
void indent();
77 LUNCHBOX_API
void exdent();
104 static LUNCHBOX_API
Log&
instance(
const char* file,
const int line );
107 static LUNCHBOX_API
void exit();
110 static LUNCHBOX_API
void reset();
116 static LUNCHBOX_API
int getLogLevel(
const char* level );
119 static LUNCHBOX_API
void setOutput( std::ostream& stream );
122 static LUNCHBOX_API
bool setOutput(
const std::string& file );
125 static LUNCHBOX_API std::ostream&
getOutput ();
137 static const Clock& getClock();
139 LUNCHBOX_API
void setThreadName(
const std::string& name );
140 LUNCHBOX_API
const std::string& getThreadName()
const;
143 detail::Log*
const impl_;
151 Log& operator = (
const Log& );
153 void setLogInfo(
const char* file,
const int line );
161 LUNCHBOX_API std::ostream&
indent( std::ostream& os );
163 LUNCHBOX_API std::ostream&
exdent( std::ostream& os );
166 LUNCHBOX_API std::ostream&
disableFlush( std::ostream& os );
168 LUNCHBOX_API std::ostream&
enableFlush( std::ostream& os );
170 LUNCHBOX_API std::ostream&
forceFlush( std::ostream& os );
173 LUNCHBOX_API std::ostream&
disableHeader( std::ostream& os );
175 LUNCHBOX_API std::ostream&
enableHeader( std::ostream& os );
187 #define LBERROR (lunchbox::Log::level >= lunchbox::LOG_ERROR) && \
188 lunchbox::Log::instance( __FILE__, __LINE__ )
190 #define LBWARN LBERROR
192 #define LBINFO (lunchbox::Log::level >= lunchbox::LOG_INFO) && \
193 lunchbox::Log::instance( __FILE__, __LINE__ )
195 #define LBDEBUG (lunchbox::Log::level >= lunchbox::LOG_DEBUG) && \
196 lunchbox::Log::instance( __FILE__, __LINE__ )
199 # define LBVERB if( false ) \
200 lunchbox::Log::instance( __FILE__, __LINE__ )
203 # define LBVERB (lunchbox::Log::level >= lunchbox::LOG_VERB) && \
204 lunchbox::Log::instance( __FILE__, __LINE__ )
211 #define LBLOG(topic) (lunchbox::Log::topics & (topic)) && \
212 lunchbox::Log::instance( __FILE__, __LINE__ )
218 #define LBTHROW(exc) \
220 LBDEBUG << exc.what() << std::endl; \
224 #endif //LUNCHBOX_LOG_H
std::ostream & enableFlush(std::ostream &os)
Re-enable flushing of the Log stream.
std::ostream & exdent(std::ostream &os)
Decrease the indentation level of the Log stream.
Defines export visibility macros for library Lunchbox.
Basic type definitions not provided by the operating system.
static std::string & getLogLevelString()
The string representation of the current log level.
A class for time measurements.
static void setClock(Clock *clock)
Set the reference clock.
static int level
The current log level.
void forceFlush()
Flush all buffered log data.
LogTopic
The logging topics.
LogLevel
The logging levels.
void indent()
Indent subsequent log output by one level.
void enableFlush()
Re-enable flushing of the log on endl.
void disableHeader()
Disable prefix printing for subsequent new lines.
Output informational messages.
std::ostream & enableHeader(std::ostream &os)
Re-enable printing of the Log header.
std::ostream & stopBlock(std::ostream &os)
Exdent, denable flush and header to stop block print.
void exdent()
Un-indent subsequent log output by one level.
std::ostream & disableHeader(std::ostream &os)
Disable printing of the Log header for subsequent lines.
Output critical errors and warnings.
friend void perThreadDelete(T *)
Default PerThread destructor deleting the object.
Output debugging information.
static int getLogLevel(const char *level)
static void setOutput(std::ostream &stream)
Change the output stream.
Abstraction layer and common utilities for multi-threaded programming.
std::ostream & forceFlush(std::ostream &os)
Flush the Log stream regardless of the auto-flush state.
std::ostream & indent(std::ostream &os)
Increases the indentation level of the Log stream, causing subsequent lines to be intended by four ch...
Log exception within LBTHROW.
static Log & instance()
The per-thread logger.
static unsigned topics
The current log topics.
static std::ostream & getOutput()
Get the current output stream.
void disableFlush()
Disable flushing of the log on endl.
void enableHeader()
Re-enable prefix printing for subsequent new lines.
static void exit()
Exit the log instance for the current thread.
Log topics for other namespaces start here.
std::ostream & startBlock(std::ostream &os)
Indent, disable flush and header for block printing.
std::ostream & disableFlush(std::ostream &os)
Disable flushing of the Log stream.