27 #ifndef LUNCHBOX_LOG_H
28 #define LUNCHBOX_LOG_H
31 #include <lunchbox/compiler.h>
66 namespace detail {
class Log; }
74 class Log :
public std::ostream
78 LUNCHBOX_API
void indent();
81 LUNCHBOX_API
void exdent();
108 static LUNCHBOX_API
Log&
instance(
const char* file,
const int line );
111 static LUNCHBOX_API
void exit();
114 static LUNCHBOX_API
void reset();
123 static LUNCHBOX_API
void setOutput( std::ostream& stream );
126 static LUNCHBOX_API
bool setOutput(
const std::string& file );
129 static LUNCHBOX_API std::ostream&
getOutput ();
141 static const Clock& getClock();
143 LUNCHBOX_API
void setThreadName(
const std::string& name );
144 LUNCHBOX_API
const std::string& getThreadName()
const;
147 detail::Log*
const impl_;
155 Log& operator = (
const Log& );
157 void setLogInfo(
const char* file,
const int line );
165 LUNCHBOX_API std::ostream&
indent( std::ostream& os );
167 LUNCHBOX_API std::ostream&
exdent( std::ostream& os );
170 LUNCHBOX_API std::ostream&
disableFlush( std::ostream& os );
172 LUNCHBOX_API std::ostream&
enableFlush( std::ostream& os );
174 LUNCHBOX_API std::ostream&
forceFlush( std::ostream& os );
177 LUNCHBOX_API std::ostream&
disableHeader( std::ostream& os );
179 LUNCHBOX_API std::ostream&
enableHeader( std::ostream& os );
191 #define LBERROR (lunchbox::Log::level >= lunchbox::LOG_ERROR) && \
192 lunchbox::Log::instance( __FILE__, __LINE__ )
194 #define LBWARN (lunchbox::Log::level >= lunchbox::LOG_WARN) && \
195 lunchbox::Log::instance( __FILE__, __LINE__ )
197 #define LBINFO (lunchbox::Log::level >= lunchbox::LOG_INFO) && \
198 lunchbox::Log::instance( __FILE__, __LINE__ )
201 # define LBVERB if( false ) \
202 lunchbox::Log::instance( __FILE__, __LINE__ )
205 # define LBVERB (lunchbox::Log::level >= lunchbox::LOG_VERB) && \
206 lunchbox::Log::instance( __FILE__, __LINE__ )
213 #define LBLOG(topic) (lunchbox::Log::topics & (topic)) && \
214 lunchbox::Log::instance( __FILE__, __LINE__ )
220 #define LBTHROW(exc) \
222 LBINFO << exc.what() << std::endl; \
226 #endif //LUNCHBOX_LOG_H
LUNCHBOX_API void enableFlush()
Re-enable flushing of the log on endl.
LUNCHBOX_API std::ostream & forceFlush(std::ostream &os)
Flush the Log stream regardless of the auto-flush state.
Defines export visibility macros for Lunchbox.
static LUNCHBOX_API void setOutput(std::ostream &stream)
Change the output stream.
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 LUNCHBOX_API std::ostream & getOutput()
Get the current output stream.
LogTopic
The logging topics.
LogLevel
The logging levels.
static LUNCHBOX_API void exit()
Exit the log instance for the current thread.
Output informational messages.
LUNCHBOX_API std::ostream & enableFlush(std::ostream &os)
Re-enable flushing of the Log stream.
std::ostream & stopBlock(std::ostream &os)
Exdent, denable flush and header to stop block print.
LUNCHBOX_API std::ostream & disableHeader(std::ostream &os)
Disable printing of the Log header for subsequent lines.
LUNCHBOX_API std::ostream & enableHeader(std::ostream &os)
Re-enable printing of the Log header.
LUNCHBOX_API void disableFlush()
Disable flushing of the log on endl.
LUNCHBOX_API void disableHeader()
Disable prefix printing for subsequent new lines.
LUNCHBOX_API void enableHeader()
Re-enable prefix printing for subsequent new lines.
LUNCHBOX_API void indent()
Indent subsequent log output by one level.
friend void perThreadDelete(T *)
Default PerThread destructor deleting the object.
static LUNCHBOX_API Log & instance()
The per-thread logger.
static LUNCHBOX_API int level
The current log level.
LUNCHBOX_API std::ostream & exdent(std::ostream &os)
Decrease the indentation level of the Log stream.
LUNCHBOX_API 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.
LUNCHBOX_API std::ostream & disableFlush(std::ostream &os)
Disable flushing of the Log stream.
static LUNCHBOX_API unsigned topics
The current log topics.
LUNCHBOX_API void exdent()
Un-indent subsequent log output by one level.
Output potentially critical warnings.
LUNCHBOX_API void forceFlush()
Flush all buffered log data.
Log topics for other namespaces start here.
static LUNCHBOX_API void setClock(Clock *clock)
Set the reference clock.
std::ostream & startBlock(std::ostream &os)
Indent, disable flush and header for block printing.
static LUNCHBOX_API int getLogLevel(const char *level)