OpenMS
Loading...
Searching...
No Matches
LogStream.h File Reference
#include <OpenMS/CONCEPT/Macros.h>
#include <OpenMS/DATASTRUCTURES/StringUtils.h>
#include <atomic>
#include <sstream>
#include <iostream>
#include <list>
#include <vector>
#include <ctime>
#include <map>

Go to the source code of this file.

Classes

class  LogStreamBuf
 Stream buffer used by LogStream. More...
 
struct  LogStreamBuf::StreamStruct
 Holds a stream that is connected to the LogStream. It also includes the minimum and maximum level at which the LogStream redirects messages to this stream. More...
 
struct  LogStreamBuf::LogCacheStruct
 Holds a counter of occurrences and an index for the occurrence sequence of the corresponding log message. More...
 
class  LogStream
 Log Stream Class. More...
 
struct  LogStream::GuardedRemoval
 A destination that LogSinkGuard removed from a global stream (see removeForGuard_()), restored with its prefix and id. More...
 
class  LogSinkGuard
 RAII guard that temporarily removes an attached stream from a LogStream and re-inserts it on scope exit. More...
 
struct  LogVoidify
 Turns a whole message into a void expression, which OPENMS_LOG_DEBUG skips when debug output is disabled. More...
 

Namespaces

namespace  OpenMS
 Main OpenMS namespace.
 
namespace  OpenMS::Logger
 Log streams.
 

Macros

#define OPENMS_LOG_FATAL_ERROR    OpenMS::getThreadLocalLogFatal() << past_last_slash(__FILE__) << "(" << __LINE__ << "): "
 Macro for fatal errors (processing stops) - includes file and line info.
 
#define OPENMS_LOG_ERROR    OpenMS::getThreadLocalLogError()
 Macro for non-fatal errors (processing continues)
 
#define OPENMS_LOG_WARN    OpenMS::getThreadLocalLogWarn()
 Macro for warnings.
 
#define OPENMS_LOG_INFO    OpenMS::getThreadLocalLogInfo()
 Macro for information/status messages.
 
#define OPENMS_LOG_DEBUG
 
#define OPENMS_LOG_DEBUG_NOFILE    !OpenMS::getThreadLocalLogDebug().good() ? (void)0 : OpenMS::Logger::LogVoidify() & OpenMS::getThreadLocalLogDebug()
 Macro for debug information (without file info), see OPENMS_LOG_DEBUG.
 

Functions

Logger::LogStream & getThreadLocalLogFatal ()
 Get thread-local fatal error log stream.
 
Logger::LogStream & getThreadLocalLogError ()
 Get thread-local error log stream.
 
Logger::LogStream & getThreadLocalLogWarn ()
 Get thread-local warning log stream.
 
Logger::LogStream & getThreadLocalLogInfo ()
 Get thread-local info log stream.
 
Logger::LogStream & getThreadLocalLogDebug ()
 Get thread-local debug log stream.
 
void setConsoleDebugLogging (bool enabled)
 Enables or disables writing OPENMS_LOG_DEBUG messages to std::cout.
 
Global LogStream accessor functions

These functions provide access to global LogStream instances for configuration purposes (e.g., adding/removing output streams). For actual logging, use the OPENMS_LOG_* macros which use thread-local streams to avoid data races.

Warning
Direct logging to global streams is NOT thread-safe. Use OPENMS_LOG_* macros instead.
Logger::LogStream & getGlobalLogFatal ()
 Get the global fatal error log stream for configuration purposes.
 
Logger::LogStream & getGlobalLogError ()
 Get the global error log stream for configuration purposes.
 
Logger::LogStream & getGlobalLogWarn ()
 Get the global warning log stream for configuration purposes.
 
Logger::LogStream & getGlobalLogInfo ()
 Get the global info log stream for configuration purposes.
 
Logger::LogStream & getGlobalLogDebug ()
 Get the global debug log stream for configuration purposes.
 

Class Documentation

◆ OpenMS::Logger::LogStreamBuf::LogCacheStruct

struct OpenMS::Logger::LogStreamBuf::LogCacheStruct

Holds a counter of occurrences and an index for the occurrence sequence of the corresponding log message.

Class Members
int counter
Size timestamp

◆ OpenMS::Logger::LogStream::GuardedRemoval

struct OpenMS::Logger::LogStream::GuardedRemoval

A destination that LogSinkGuard removed from a global stream (see removeForGuard_()), restored with its prefix and id.

Class Members
Size id = 0
string prefix
bool reinsert = false

Macro Definition Documentation

◆ OPENMS_LOG_DEBUG

#define OPENMS_LOG_DEBUG
Value:
!OpenMS::getThreadLocalLogDebug().good() ? (void)0 : OpenMS::Logger::LogVoidify() & \
OpenMS::getThreadLocalLogDebug() << past_last_slash(__FILE__) << "(" << __LINE__ << "): "
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Logger::LogStream & getThreadLocalLogDebug()
Get thread-local debug log stream.

Macro for debug information - includes file and line info.

Without a destination for debug output on the calling thread (the default, unless e.g. a TOPP tool runs with -debug), the whole message is skipped: its arguments are not evaluated. As it is a void expression, use getThreadLocalLogDebug() for anything else than writing a message.

◆ OPENMS_LOG_DEBUG_NOFILE

#define OPENMS_LOG_DEBUG_NOFILE    !OpenMS::getThreadLocalLogDebug().good() ? (void)0 : OpenMS::Logger::LogVoidify() & OpenMS::getThreadLocalLogDebug()

Macro for debug information (without file info), see OPENMS_LOG_DEBUG.

◆ OPENMS_LOG_ERROR

#define OPENMS_LOG_ERROR    OpenMS::getThreadLocalLogError()

Macro for non-fatal errors (processing continues)

◆ OPENMS_LOG_FATAL_ERROR

#define OPENMS_LOG_FATAL_ERROR    OpenMS::getThreadLocalLogFatal() << past_last_slash(__FILE__) << "(" << __LINE__ << "): "

Macro for fatal errors (processing stops) - includes file and line info.

◆ OPENMS_LOG_INFO

#define OPENMS_LOG_INFO    OpenMS::getThreadLocalLogInfo()

Macro for information/status messages.

◆ OPENMS_LOG_WARN

#define OPENMS_LOG_WARN    OpenMS::getThreadLocalLogWarn()

Macro for warnings.