28namespace Experimental {
47 return static_cast<ELogLevel>(
static_cast<int>(severity) + offset);
150 void PushFront(std::unique_ptr<RLogHandler> handler) {
fHandlers.emplace_front(std::move(handler)); }
153 void PushBack(std::unique_ptr<RLogHandler> handler) {
fHandlers.emplace_back(std::move(handler)); }
213class RLogBuilder :
public std::ostringstream {
220 const std::string &funcname)
221 : fEntry(level, channel, {filename, funcname,
line})
229 RLogManager::Get().Emit(fEntry);
243class RLogScopedVerbosity {
249 : fChannel(&channel), fPrevLevel(channel.SetVerbosity(verbosity))
252 explicit RLogScopedVerbosity(
ELogLevel verbosity) : RLogScopedVerbosity(RLogManager::Get(), verbosity) {}
253 ~RLogScopedVerbosity() { fChannel->
SetVerbosity(fPrevLevel); }
260class RLogScopedDiagCount {
261 RLogDiagCount *fCounter =
nullptr;
263 long long fInitialWarnings = 0;
265 long long fInitialErrors = 0;
267 long long fInitialFatalErrors = 0;
272 explicit RLogScopedDiagCount(RLogDiagCount &cnt)
273 : fCounter(&
cnt), fInitialWarnings(
cnt.GetNumWarnings()), fInitialErrors(
cnt.GetNumErrors()),
274 fInitialFatalErrors(
cnt.GetNumFatalErrors())
279 RLogScopedDiagCount() : RLogScopedDiagCount(RLogManager::Get()) {}
282 long long GetAccumulatedWarnings()
const {
return fCounter->GetNumWarnings() - fInitialWarnings; }
285 long long GetAccumulatedErrors()
const {
return fCounter->GetNumErrors() - fInitialErrors; }
288 long long GetAccumulatedFatalErrors()
const {
return fCounter->GetNumFatalErrors() - fInitialFatalErrors; }
291 bool HasWarningOccurred()
const {
return GetAccumulatedWarnings(); }
294 bool HasErrorOccurred()
const {
return GetAccumulatedErrors() + GetAccumulatedFatalErrors(); }
297 bool HasErrorOrWarningOccurred()
const {
return HasWarningOccurred() || HasErrorOccurred(); }
302inline RLogChannel &GetChannelOrManager()
306inline RLogChannel &GetChannelOrManager(RLogChannel &channel)
316 return mgr.GetVerbosity();
324#define R__LOG_PRETTY_FUNCTION __FUNCSIG__
326#define R__LOG_PRETTY_FUNCTION __PRETTY_FUNCTION__
344#define R__LOG_TO_CHANNEL(SEVERITY, CHANNEL) \
345 ((SEVERITY < ROOT::Experimental::ELogLevel::kInfo + 0) || \
346 ROOT::Experimental::Internal::GetChannelOrManager(CHANNEL).GetEffectiveVerbosity( \
347 ROOT::Experimental::RLogManager::Get()) >= SEVERITY) && \
348 ROOT::Experimental::Detail::RLogBuilder(SEVERITY, ROOT::Experimental::Internal::GetChannelOrManager(CHANNEL), \
349 __FILE__, __LINE__, R__LOG_PRETTY_FUNCTION)
361#define R__LOG_FATAL(...) R__LOG_TO_CHANNEL(ROOT::Experimental::ELogLevel::kFatal, __VA_ARGS__)
362#define R__LOG_ERROR(...) R__LOG_TO_CHANNEL(ROOT::Experimental::ELogLevel::kError, __VA_ARGS__)
363#define R__LOG_WARNING(...) R__LOG_TO_CHANNEL(ROOT::Experimental::ELogLevel::kWarning, __VA_ARGS__)
364#define R__LOG_INFO(...) R__LOG_TO_CHANNEL(ROOT::Experimental::ELogLevel::kInfo, __VA_ARGS__)
365#define R__LOG_DEBUG(DEBUGLEVEL, ...) R__LOG_TO_CHANNEL(ROOT::Experimental::ELogLevel::kDebug + DEBUGLEVEL, __VA_ARGS__)
A log configuration for a channel, e.g.
RLogChannel(const std::string &name)
Construct a log channel given its name, which is part of the diagnostics.
ELogLevel fVerbosity
Verbosity of this channel. By default, use the global verbosity.
RLogChannel()=default
Construct an anonymous channel.
ELogLevel GetEffectiveVerbosity(const RLogManager &mgr) const
std::string fName
Name as shown in diagnostics.
ELogLevel GetVerbosity() const
ELogLevel SetVerbosity(ELogLevel verbosity)
const std::string & GetName() const
RLogChannel(ELogLevel verbosity)
Construct an anonymous channel with a default vebosity.
Keep track of emitted errors and warnings.
std::atomic< long long > fNumFatalErrors
Number of errors.
std::atomic< long long > fNumWarnings
void Increment(ELogLevel severity)
Increase warning or error count.
long long GetNumWarnings() const
Number of fatal errors.
std::atomic< long long > fNumErrors
Number of warnings.
long long GetNumFatalErrors() const
Returns the current number of fatal errors.
long long GetNumErrors() const
Returns the current number of errors.
A diagnostic that can be emitted by the RLogManager.
RLogEntry(ELogLevel level, RLogChannel &channel, const RLogLocation &loc)
RLogEntry(ELogLevel level, RLogChannel &channel)
Abstract RLogHandler base class.
virtual bool Emit(const RLogEntry &entry)=0
Emit a log entry.
A RLogHandler that multiplexes diagnostics to different client RLogHandlers and keeps track of the su...
std::list< std::unique_ptr< RLogHandler > > fHandlers
std::unique_ptr< RLogHandler > Remove(RLogHandler *handler)
Remove and return the given log handler. Returns nullptr if not found.
static RLogManager & Get()
RLogManager(std::unique_ptr< RLogHandler > lh)
Initialize taking a RLogHandler.
bool Emit(const RLogEntry &entry) override
Emit a log entry.
void PushFront(std::unique_ptr< RLogHandler > handler)
Add a RLogHandler in the front - to be called before all others.
void PushBack(std::unique_ptr< RLogHandler > handler)
Add a RLogHandler in the back - to be called after all others.
ELogLevel operator+(ELogLevel severity, int offset)
ELogLevel
Kinds of diagnostics.
@ kInfo
Informational messages; used for instance for tracing.
@ kDebug
Debug information; only useful for developers; can have added verbosity up to 255-kDebug.
@ kFatal
An error which causes further processing to be unreliable.
@ kWarning
Warnings about likely unexpected behavior.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
A diagnostic location, part of an RLogEntry.