Go to the documentation of this file.
27 #include <tpie/tpie_export.h>
31 #include <tpie/config.h>
40 std::stack<std::string> groups;
55 void log(
log_level level,
const char * message,
size_t);
61 void begin_group(
const std::string & name);
68 std::string build_prefix(
size_t length);
74 std::stack<std::string> groups;
88 void log(
log_level level,
const char * message,
size_t size);
94 void begin_group(
const std::string & name);
101 std::string build_prefix(
size_t length);
125 TPIE_EXPORT
extern std::vector<std::shared_ptr<logstream> > log_instances;
127 TPIE_EXPORT
void initiate_log_level(
log_level level);
129 TPIE_EXPORT
void flush_logs();
133 inline logstream & get_log_by_level(
log_level level) {
134 using namespace log_bits;
135 if (log_instances.size() <= level || log_instances[level].get() == 0)
136 initiate_log_level(level);
137 return *log_instances[level];
184 inline bool get_orig() {
return m_orig;}
186 m_orig = log_bits::logging_disabled;
187 log_bits::logging_disabled = !e;
190 log_bits::logging_disabled = m_orig;
233 set_level(mi.get_level());
237 template <
typename T>
253 void add_target(
log_target * t) { add_log_target(t); }
255 void remove_target(
log_target * t) { remove_log_target(t); }
266 #define TP_LOG_FLUSH_LOG tpie::get_log().flush()
270 #define TP_LOG_FATAL(msg) tpie::log_fatal() << msg
271 #define TP_LOG_WARNING(msg) tpie::log_warning() << msg
273 #define TP_LOG_APP_DEBUG(msg) tpie::log_app_debug() << msg
275 #define TP_LOG_DEBUG(msg) tpie::log_debug() << msg
277 #define TP_LOG_MEM_DEBUG(msg) tpie::log_mem_debug() << msg
280 #define TP_LOG_ID_MSG __FILE__ << " line " << __LINE__ << ": "
283 #define TP_LOG_FATAL_ID(msg) TP_LOG_FATAL(TP_LOG_ID_MSG << msg << std::endl)
286 #define TP_LOG_WARNING_ID(msg) TP_LOG_WARNING(TP_LOG_ID_MSG << msg << std::endl)
289 #define TP_LOG_APP_DEBUG_ID(msg) TP_LOG_APP_DEBUG(TP_LOG_ID_MSG << msg << std::endl)
292 #define TP_LOG_DEBUG_ID(msg) TP_LOG_DEBUG(TP_LOG_ID_MSG << msg << std::endl)
295 #define TP_LOG_MEM_DEBUG_ID(msg) TP_LOG_MEM_DEBUG(TP_LOG_ID_MSG << msg << std::endl)
297 #else // !TPL_LOGGING
300 #define TP_LOG_FATAL(msg)
301 #define TP_LOG_WARNING(msg)
302 #define TP_LOG_APP_DEBUG(msg)
303 #define TP_LOG_DEBUG(msg)
304 #define TP_LOG_MEM_DEBUG(msg)
306 #define TP_LOG_FATAL_ID(msg)
307 #define TP_LOG_WARNING_ID(msg)
308 #define TP_LOG_APP_DEBUG_ID(msg)
309 #define TP_LOG_DEBUG_ID(msg)
310 #define TP_LOG_MEM_DEBUG_ID(msg)
312 #define TP_LOG_FLUSH_LOG {}
314 #endif // TPL_LOGGING
318 #endif // _TPIE_LOG_H
@ LOG_USER1
Logging levels to be further defined by user applications.
logstream & log_mem_debug()
Return logstream for writing mem_debug log messages.
A simple logger that writes messages to stderr.
@ LOG_INFORMATIONAL
LOG_INFORMATIONAL is used for informational messagse.
log_level
TPIE logging levels, from higest priority to lowest.
@ LOG_FATAL
LOG_FATAL is the highest error level and is used for all kinds of errors that would normally impair s...
@ LOG_APP_DEBUG
LOG_APP_DEBUG can be used by applications built on top of TPIE, for logging debugging information.
logstream & log_error()
Return logstream for writing error log messages.
logstream & log_info()
Return logstream for writing info log messages.
void finish_default_log()
Used by tpie_finish to deinitialize the log subsystem.
A simple logger that writes messages to a tpie temporary file.
logstream & log_pipe_debug()
Return logstream for writing pipe_debug log messages.
logstream & log_warning()
Return logstream for writing warning log messages.
log_bits::log_selector get_log()
Returns the only logstream object.
logstream & log_debug()
Return logstream for writing debug log messages.
logstream & log_app_debug()
Return logstream for writing app_debug log messages.
@ LOG_DEBUG
LOG_DEBUG is the lowest level and is used by the TPIE library for logging debugging information.
@ LOG_ERROR
LOG_ERROR is used for none fatal errors.
logstream & log_fatal()
Return logstream for writing fatal log messages.
A log is like a regular output stream, but it also supports messages at different priorities,...
@ LOG_WARNING
LOG_WARNING is used for warnings.
@ LOG_MEM_DEBUG
Logging level for warnings concerning memory allocation and deallocation.
const std::string & log_name()
Returns the file name of the log stream.
void init_default_log()
Used by tpie_init to initialize the log subsystem.