30 #include <tpie/config.h>
39 std::stack<std::string> groups;
67 std::string build_prefix(
size_t length);
73 std::stack<std::string> groups;
87 void log(
log_level level,
const char * message,
size_t size);
100 std::string build_prefix(
size_t length);
124 extern std::vector<std::shared_ptr<logstream> > log_instances;
126 void initiate_log_level(
log_level level);
132 inline logstream & get_log_by_level(
log_level level) {
133 using namespace log_bits;
134 if (log_instances.size() <= level || log_instances[level].get() == 0)
135 initiate_log_level(level);
136 return *log_instances[level];
178 inline bool get_orig() {
return m_orig;}
180 m_orig = log_bits::logging_disabled;
181 log_bits::logging_disabled = !e;
184 log_bits::logging_disabled = m_orig;
225 set_level(mi.get_level());
229 template <
typename T>
245 void add_target(
log_target * t) { add_log_target(t); }
247 void remove_target(
log_target * t) { remove_log_target(t); }
258 #define TP_LOG_FLUSH_LOG tpie::get_log().flush()
262 #define TP_LOG_FATAL(msg) tpie::log_fatal() << msg
263 #define TP_LOG_WARNING(msg) tpie::log_warning() << msg
265 #define TP_LOG_APP_DEBUG(msg) tpie::log_app_debug() << msg
267 #define TP_LOG_DEBUG(msg) tpie::log_debug() << msg
269 #define TP_LOG_MEM_DEBUG(msg) tpie::log_mem_debug() << msg
272 #define TP_LOG_ID_MSG __FILE__ << " line " << __LINE__ << ": "
275 #define TP_LOG_FATAL_ID(msg) TP_LOG_FATAL(TP_LOG_ID_MSG << msg << std::endl)
278 #define TP_LOG_WARNING_ID(msg) TP_LOG_WARNING(TP_LOG_ID_MSG << msg << std::endl)
281 #define TP_LOG_APP_DEBUG_ID(msg) TP_LOG_APP_DEBUG(TP_LOG_ID_MSG << msg << std::endl)
284 #define TP_LOG_DEBUG_ID(msg) TP_LOG_DEBUG(TP_LOG_ID_MSG << msg << std::endl)
287 #define TP_LOG_MEM_DEBUG_ID(msg) TP_LOG_MEM_DEBUG(TP_LOG_ID_MSG << msg << std::endl)
289 #else // !TPL_LOGGING
292 #define TP_LOG_FATAL(msg)
293 #define TP_LOG_WARNING(msg)
294 #define TP_LOG_APP_DEBUG(msg)
295 #define TP_LOG_DEBUG(msg)
296 #define TP_LOG_MEM_DEBUG(msg)
298 #define TP_LOG_FATAL_ID(msg)
299 #define TP_LOG_WARNING_ID(msg)
300 #define TP_LOG_APP_DEBUG_ID(msg)
301 #define TP_LOG_DEBUG_ID(msg)
302 #define TP_LOG_MEM_DEBUG_ID(msg)
304 #define TP_LOG_FLUSH_LOG {}
306 #endif // TPL_LOGGING
310 #endif // _TPIE_LOG_H
Logging level for warnings concerning memory allocation and deallocation.
A log is like a regular output stream, but it also supports messages at different priorities...
LOG_FATAL is the highest error level and is used for all kinds of errors that would normally impair s...
LOG_ERROR is used for none fatal errors.
LOG_WARNING is used for warnings.
A simple logger that writes messages to a tpie temporary file.
logstream & log_info()
Return logstream for writing info log messages.
A simple logger that writes messages to stderr.
logstream class used by definitions in tpie_log.h.
file_log_target(log_level threshold)
Construct a new file logger.
const std::string & log_name()
Returns the file name of the log stream.
void log(log_level level, const char *message, size_t size)
Implement log_target virtual method to record message.
LOG_INFORMATIONAL is used for informational messagse.
stderr_log_target(log_level threshold)
Construct a new stderr logger.
void end_group()
Closes the most recently created logging group.
log_level
TPIE logging levels, from higest priority to lowest.
logstream & log_debug()
Return logstream for writing debug log messages.
void begin_group(const std::string &name)
Creates a new logging group.
logstream & log_fatal()
Return logstream for writing fatal log messages.
logstream & log_app_debug()
Return logstream for writing app_debug log messages.
Logging levels to be further defined by user applications.
log_bits::log_selector get_log()
Returns the only logstream object.
void init_default_log()
Used by tpie_init to initialize the log subsystem.
void begin_group(const std::string &name)
Creates a new logging group.
void end_group()
Closes the most recently created logging group.
LOG_DEBUG is the lowest level and is used by the TPIE library for logging debugging information...
void finish_default_log()
Used by tpie_finish to deinitialize the log subsystem.
logstream & log_error()
Return logstream for writing error log messages.
logstream & log_warning()
Return logstream for writing warning log messages.
logstream & log_mem_debug()
Return logstream for writing mem_debug log messages.
void log(log_level level, const char *message, size_t)
Implement log_target virtual method to record message.
LOG_APP_DEBUG can be used by applications built on top of TPIE, for logging debugging information...