225 char * pbuf_ =
nullptr;
232 std::atomic<Size> version_{0};
467 void setPrefix(
const std::ostream & s,
const std::string & prefix);
496 friend struct ThreadLocalLogAccess;
503 bool reinsert =
false;
589 : log_stream_(log_stream), stream_(stream), was_attached_(log_stream.hasStream(stream))
596 removal_ = log_stream_.removeForGuard_(stream_);
606 log_stream_.restoreForGuard_(stream_, removal_);
683#define OPENMS_LOG_FATAL_ERROR \
684 OpenMS::getThreadLocalLogFatal() << past_last_slash(__FILE__) << "(" << __LINE__ << "): "
687#define OPENMS_LOG_ERROR \
688 OpenMS::getThreadLocalLogError()
691#define OPENMS_LOG_WARN \
692 OpenMS::getThreadLocalLogWarn()
695#define OPENMS_LOG_INFO \
696 OpenMS::getThreadLocalLogInfo()
714#define OPENMS_LOG_DEBUG \
715 !OpenMS::getThreadLocalLogDebug().good() ? (void)0 : OpenMS::Logger::LogVoidify() & \
716 OpenMS::getThreadLocalLogDebug() << past_last_slash(__FILE__) << "(" << __LINE__ << "): "
719#define OPENMS_LOG_DEBUG_NOFILE \
720 !OpenMS::getThreadLocalLogDebug().good() ? (void)0 : OpenMS::Logger::LogVoidify() & OpenMS::getThreadLocalLogDebug()
Color and style the fonts shown on cout/cerr (or other streams)
Definition Colorizer.h:71
RAII guard that temporarily removes an attached stream from a LogStream and re-inserts it on scope ex...
Definition LogStream.h:579
LogSinkGuard(LogSinkGuard &&)=delete
LogSinkGuard(const LogSinkGuard &)=delete
LogSinkGuard & operator=(const LogSinkGuard &)=delete
LogSinkGuard(LogStream &log_stream, std::ostream &stream)
Construct a guard that removes stream, if attached, and re-inserts it on destruction.
Definition LogStream.h:588
LogSinkGuard & operator=(LogSinkGuard &&)=delete
LogStream::GuardedRemoval removal_
what the guard removed, restored on destruction
Definition LogStream.h:621
~LogSinkGuard()
Destructor writes output pending inside the scope to the other destinations, then restores the sink.
Definition LogStream.h:600
LogStream & log_stream_
Definition LogStream.h:616
std::ostream & stream_
Definition LogStream.h:617
const bool was_attached_
was the sink attached when the guard was constructed? if not, the guard does nothing
Definition LogStream.h:619
Stream buffer used by LogStream.
Definition LogStream.h:80
Size getNextLogCounter_()
Returns the next free index for a log message.
void updateFromParent_()
Updates stream_list_ if parent_ changed its destinations since the last update. Locks the sink mutex.
void updateFromParentLocked_()
Same as updateFromParent_(), but the caller holds the sink mutex.
std::map< Size, std::string > log_time_cache_
Cache of the occurrence sequence of the last two log messages.
Definition LogStream.h:264
void write_(StreamStruct &s, const std::string &line)
Writes line to the destination s, with its prefix and color. The caller holds the sink mutex.
void forgetRepeatsAfterChange_(const std::vector< Size > &previous)
std::string expandPrefix_(const std::string &prefix, time_t time) const
Interpret the prefix format string and return the expanded prefix.
void rebuildStreamList_()
Rebuilds stream_list_ from parent_'s destinations and this buffer's own changes. The caller holds the...
LogStreamBuf(LogStreamBuf *source_buf, Colorizer *col=nullptr)
std::list< StreamStruct > & prefixableStreams_()
Entries whose prefix may be changed: stream_list_, or own_streams_ for a following buffer (the prefix...
std::string level_
Definition LogStream.h:226
std::list< StreamStruct > stream_list_
Destinations of this buffer (for a following buffer: derived from parent_, own_streams_ and hidden_id...
Definition LogStream.h:227
int counter
Definition LogStream.h:252
std::vector< Size > destinations_() const
The destinations in stream_list_ (their StreamStruct::id), sorted.
Size timestamp
Definition LogStream.h:251
std::vector< std::string > repeatSummaries_() const
"<message> occurred N times" for each cached message that was repeated
const std::list< StreamStruct > & getStreamList_() const
std::vector< Size > hidden_ids_
Definition LogStream.h:239
bool guarded_(const std::ostream *stream) const
Is stream suppressed by a LogSinkGuard on this following buffer (see guarded_streams_)?
std::map< std::string, LogCacheStruct > log_cache_
Cache of the last two log messages.
Definition LogStream.h:262
LogStreamBuf(const std::string &log_level=UNKNOWN_LOG_LEVEL, Colorizer *col=nullptr)
int syncLF_()
Non-lock acquiring sync function called in the d'tor.
void setLevel(std::string level)
void distributeNew_(const std::string &line)
void destinationsChanged_()
Publishes a change of the destinations to following buffers (or rebuilds stream_list_)....
std::vector< const std::ostream * > guarded_streams_
Streams that a LogSinkGuard suppresses on this following buffer (one entry per guard),...
Definition LogStream.h:241
std::string addToCache_(std::string const &line)
std::string incomplete_line_
Definition LogStream.h:228
void distribute_(const std::string &outstring)
Distribute a new message to connected streams.
std::list< StreamStruct > & getStreamList_()
Returns the stream list (owned or shared)
static const std::string UNKNOWN_LOG_LEVEL
Definition LogStream.h:89
bool isInCache_(std::string const &line)
Checks if the line is already in the cache.
std::list< StreamStruct > own_streams_
Destinations inserted into this following buffer; they replace parent_'s entry for the same stream.
Definition LogStream.h:236
static const time_t MAX_TIME
Definition LogStream.h:88
int overflow(int c=-1) override
Holds a counter of occurrences and an index for the occurrence sequence of the corresponding log mess...
Definition LogStream.h:250
Log Stream Class.
Definition LogStream.h:335
bool hasStream_(std::ostream &stream)
LogStream(LogStreamBuf *buf=nullptr, bool delete_buf=true, std::ostream *stream=nullptr)
void followParent_()
For a thread-local stream: applies changes of the global destinations made since the last call,...
LogStream * threadLocalFollower_()
For a global stream: the calling thread's thread-local stream of the same level, or nullptr.
void insert(std::ostream &s)
bool hasStream(std::ostream &stream)
Is stream currently one of this LogStream's output destinations?
std::list< LogStreamBuf::StreamStruct >::iterator StreamIterator
Definition LogStream.h:489
GuardedRemoval removeForGuard_(std::ostream &s)
GuardedRemoval detachLocked_(std::ostream &s)
Removes s from the destinations (for a thread-local stream: hides inherited ones) and returns what it...
~LogStream() override
Clears all message buffers.
LogStreamBuf * operator->()
Arrow operator.
std::string prefix
Definition LogStream.h:504
void setPrefix(const std::ostream &s, const std::string &prefix)
bool delete_buffer_
Definition LogStream.h:544
void drain_()
Writes pending text (also an incomplete line) and repeat counts to the current destinations.
void setPrefix(const std::string &prefix)
Set prefix of all output streams, details see setPrefix method with ostream.
void setLevel(std::string level)
void remove(std::ostream &s)
void restoreForGuard_(std::ostream &s, const GuardedRemoval &removal)
StreamIterator findStream_(const std::ostream &stream)
void flushIncomplete()
Flush any incomplete line (text not terminated by newline) to all streams.
A destination that LogSinkGuard removed from a global stream (see removeForGuard_()),...
Definition LogStream.h:502
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Logger::LogStream & getGlobalLogDebug()
Get the global debug log stream for configuration purposes.
Logger::LogStream & getThreadLocalLogDebug()
Get thread-local debug log stream.
void setConsoleDebugLogging(bool enabled)
Enables or disables writing OPENMS_LOG_DEBUG messages to std::cout.
Logger::LogStream & getGlobalLogError()
Get the global error log stream for configuration purposes.
Logger::LogStream & getThreadLocalLogInfo()
Get thread-local info log stream.
Logger::LogStream & getThreadLocalLogWarn()
Get thread-local warning log stream.
Logger::LogStream & getGlobalLogFatal()
Get the global fatal error log stream for configuration purposes.
Logger::LogStream & getThreadLocalLogFatal()
Get thread-local fatal error log stream.
Logger::LogStream & getGlobalLogWarn()
Get the global warning log stream for configuration purposes.
Logger::LogStream & getThreadLocalLogError()
Get thread-local error log stream.
Logger::LogStream & getGlobalLogInfo()
Get the global info log stream for configuration purposes.
Holds a stream that is connected to the LogStream. It also includes the minimum and maximum level at ...
Definition LogStream.h:169
std::string prefix
Definition LogStream.h:171
Size id
Unique for each insertion: a stream inserted again, or a new stream at the address of a destroyed one...
Definition LogStream.h:173
StreamStruct()
Definition LogStream.h:175
std::ostream * stream
Definition LogStream.h:170
Turns a whole message into a void expression, which OPENMS_LOG_DEBUG skips when debug output is disab...
Definition LogStream.h:702
void operator&(std::ostream &) const
Definition LogStream.h:703