Go to the documentation of this file.
18 #ifndef __LIB_LIBSTD_LOG_H
19 #define __LIB_LIBSTD_LOG_H
39 #define MAKE_LOG(type, typestr, msg) \
41 if (Log::instance() && type <= Log::instance()->getMinimumLogLevel()) \
42 (*Log::instance()) << "[" typestr "] " << __FILE__ ":" << __LINE__ << " " << __FUNCTION__ << " -- " << msg << "\r\n"; \
52 MAKE_LOG(Log::Emergency, "Emergency", msg); \
53 if (Log::instance()) Log::instance()->terminate(); \
61 #define ERROR(msg) MAKE_LOG(Log::Error, "Error", msg)
68 #define WARNING(msg) MAKE_LOG(Log::Warning, "Warning", msg)
75 #define NOTICE(msg) MAKE_LOG(Log::Notice, "Notice", msg)
82 #define INFO(msg) MAKE_LOG(Log::Info, "Info", msg)
89 #define DEBUG(msg) MAKE_LOG(Log::Debug, "Debug", msg)
147 void append(
const char *str);
173 virtual void write(
const char *str) = 0;
189 void flush(
const bool force =
false);
const char * getIdent() const
Retrieve log identify.
Level m_minimumLogLevel
Minimum log level required to log.
virtual void terminate() const
Terminate the program immediately.
void setMinimumLogLevel(Level level)
Set the minimum logging level.
void flush(const bool force=false)
Flush internal buffer.
Size m_outputBufferWritten
Number of characters written in the output buffer.
Log & operator<<(Log &log, const char *str)
const char * m_ident
Identity.
void append(const char *str)
Append to buffered output.
static const Size LogBufferSize
Size of the log buffer in bytes.
virtual void write(const char *str)=0
Write to the actual output device.
unsigned int Size
Any sane size indicator cannot go negative.
char m_outputBuffer[LogBufferSize]
Output line is stored here until written using write()
Singleton design pattern: only one instance is allowed.
virtual ~Log()
Destructor.
Level getMinimumLogLevel()
Get the minimum logging level.
void setIdent(const char *ident)
Set log identity.
Level
Logging level values.