Tomographer
v5.2
Tomographer C++ Framework Documentation
|
Wrapper logger to call non-thread-safe loggers from a multithreaded environment. More...
#include <tomographer/multiprocomp.h>
Public Member Functions | |
template<typename... MoreArgs> | |
ThreadSanitizerLogger (BaseLogger &logger, MoreArgs &&...) | |
Constructor. More... | |
template<ENABLED_IF( IsBaseLoggerThreadSafe) > | |
void | emitLog (int level, const char *origin, const std::string &msg) |
Implementation of Logger::LoggerBase::emitLog() for a base logger which is thread-safe. | |
template<ENABLED_IF( Logger::LoggerTraits< BaseLogger >::HasFilterByOrigin && IsBaseLoggerThreadSafe) > | |
bool | filterByOrigin (int level, const char *origin) const |
Implementation of Logger::LoggerBase::filterByOrigin() for a base logger which is thread-safe. | |
template<ENABLED_IF( !IsBaseLoggerThreadSafe) > | |
void | emitLog (int level, const char *origin, const std::string &msg) |
Implementation of Logger::LoggerBase::emitLog() for a base logger which is not thread-safe. | |
template<ENABLED_IF( Logger::LoggerTraits< BaseLogger >::HasFilterByOrigin && !IsBaseLoggerThreadSafe) > | |
bool | filterByOrigin (int level, const char *origin) const |
Implementation of Logger::LoggerBase::filterByOrigin() for a base logger which is not thread-safe. | |
Public Member Functions inherited from Tomographer::Logger::LoggerBase< ThreadSanitizerLogger< BaseLogger > > | |
LoggerBase (int level_=INFO) | |
Construct the base logger object. More... | |
bool | enabledFor (int level_) const |
Check whether messages at the given log level are enabled. More... | |
int | level () const |
Get the log level set for this logger. More... | |
void | error (const char *origin, const char *fmt,...) |
emit an error message More... | |
void | error (const char *origin, std::string msg) |
emit an error message More... | |
void | error (const char *origin, Fn &&f) |
emit an error message More... | |
void | error (Args &&...) |
Special-case implementation for messages which are known to be discarded at compile time. | |
void | warning (const char *origin, const char *fmt,...) |
emit a warning message More... | |
void | warning (const char *origin, std::string msg) |
emit a warning message More... | |
void | warning (const char *origin, Fn &&f) |
emit a warning message More... | |
void | warning (Args &&...) |
Special-case implementation for messages which are known to be discarded at compile time. | |
void | info (const char *origin, const char *fmt,...) |
emit an information/notice message More... | |
void | info (const char *origin, std::string msg) |
emit an information/notice message More... | |
void | info (const char *origin, Fn &&f) |
emit an information/notice message More... | |
void | info (Args &&...) |
Special-case implementation for messages which are known to be discarded at compile time. | |
void | debug (const char *origin, const char *fmt,...) |
emit an debug message More... | |
void | debug (const char *origin, std::string msg) |
emit an debug message More... | |
void | debug (const char *origin, Fn &&f) |
emit an debug message More... | |
void | debug (Args &&...) |
Special-case implementation for messages which are known to be discarded at compile time. | |
void | longdebug (const char *origin, const char *fmt,...) |
emit a very verbose debugging message More... | |
void | longdebug (const char *origin, std::string msg) |
emit a very verbose debugging message More... | |
void | longdebug (const char *origin, Fn &&f) |
emit a very verbose debugging message More... | |
void | longdebug (Args &&...) |
Special-case implementation for messages which are known to be discarded at compile time. | |
void | log (int level, const char *origin, const char *fmt,...) |
emit a log message at the given log level. More... | |
void | log (int level, const char *origin, std::string msg) |
emit a log message at the given log level. More... | |
void | log (int level, const char *origin, Fn &&f) |
emit a log message at the given log level. More... | |
void | log (const char *origin, const char *fmt,...) |
emit a log message at the given log level. More... | |
void | log (const char *origin, const char *fmt, va_list ap) |
emit a log message at the given log level. More... | |
void | log (const char *origin, std::string msg) |
emit a log message at the given log level. More... | |
void | log (const char *origin, Fn f) |
emit a log message at the given log level. More... | |
void | log (Args &&...) |
Special-case implementation for messages which are known to be discarded at compile time. | |
Static Public Attributes | |
static constexpr bool | IsBaseLoggerThreadSafe = Logger::LoggerTraits<BaseLogger>::IsThreadSafe |
Additional Inherited Members | |
Public Types inherited from Tomographer::Logger::LoggerBase< ThreadSanitizerLogger< BaseLogger > > | |
enum | |
Shortcuts to properties defined in the traits class. | |
Static Public Member Functions inherited from Tomographer::Logger::LoggerBase< ThreadSanitizerLogger< BaseLogger > > | |
static bool | staticallyEnabledFor (int level) |
Check whether the logger is statically disabled for some levels. More... | |
static constexpr bool | staticallyEnabledFor () |
Static version of staticallyEnabledFor() More... | |
Protected Member Functions inherited from Tomographer::Logger::LoggerBase< ThreadSanitizerLogger< BaseLogger > > | |
int | getLevel () const |
int | getLevel () const |
ThreadSanitizerLogger< BaseLogger > * | derived () |
const ThreadSanitizerLogger< BaseLogger > * | derived () const |
void | setLogLevel (int level) |
Store a new run-time log level. More... | |
Wrapper logger to call non-thread-safe loggers from a multithreaded environment.
Wraps calls to emit log messages into a OpenMP
sections, which ensure thread-safety of the logging. Of course don't log too often, as this will drastically slow down the execution of your program!!
#pragma omp critical
blocks. —NO DON'T. It would make it complex to debug afterwards; if there is a crash, some messages may not be displayed making debugging difficult.Example usage:
Definition at line 117 of file multiprocomp.h.
|
inline |
Constructor.
This constructor accepts arbitrary more arguments and ignores them. The reason is because the task dispatcher does not know for sure which type the task-logger is (you can specify your custom type), and will always invoke the constructor with additional parameters such as a pointer to the TaskCData. Here we don't need those so we can just ignore any additional args.
Definition at line 136 of file multiprocomp.h.