ROOT
6.14/05
Reference Guide
core
base
v7
src
TLogger.cxx
Go to the documentation of this file.
1
/// \file TLogger.cxx
2
/// \ingroup Base ROOT7
3
/// \author Axel Naumann <axel@cern.ch>
4
/// \date 2015-07-07
5
/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6
/// is welcome!
7
8
/*************************************************************************
9
* Copyright (C) 1995-2015, Rene Brun and Fons Rademakers. *
10
* All rights reserved. *
11
* *
12
* For the licensing terms see $ROOTSYS/LICENSE. *
13
* For the list of contributors see $ROOTSYS/README/CREDITS. *
14
*************************************************************************/
15
16
#include "
ROOT/TLogger.hxx
"
17
#include <iostream>
18
#include <sstream>
19
20
#include "
TError.h
"
21
22
// pin vtable
23
ROOT::Experimental::TLogHandler::~TLogHandler
() {}
24
25
namespace
{
26
class
TLogHandlerDefault:
public
ROOT::Experimental::TLogHandler
{
27
public
:
28
// Returns false if further emission of this log entry should be suppressed.
29
bool
Emit
(
const
ROOT::Experimental::TLogEntry
&entry)
override
;
30
};
31
32
bool
TLogHandlerDefault::Emit(
const
ROOT::Experimental::TLogEntry
&entry)
33
{
34
constexpr
static
std::array<const char *, 5> sTag{{
"Debug"
,
"Info"
,
"Warning"
,
"Log"
,
"FATAL"
}};
35
std::stringstream strm;
36
strm <<
"ROOT "
;
37
if
(!entry.
fGroup
.empty())
38
strm <<
'['
<< entry.
fGroup
<<
"] "
;
39
strm << sTag[static_cast<int>(entry.
fLevel
)];
40
41
if
(!entry.
fFile
.empty())
42
strm <<
" "
<< entry.
fFile
<<
':'
<< entry.
fLine
;
43
if (!entry.
fFuncName
.empty())
44
strm <<
" in "
<< entry.
fFuncName
;
45
46
static
constexpr
const
int
errorLevelOld[] = {0, 1000, 2000, 3000, 6000};
47
(*
::GetErrorHandler
())(errorLevelOld[static_cast<int>(entry.
fLevel
)],
48
entry.
fLevel
==
ROOT::Experimental::ELogLevel::kFatal
,
49
strm.str().c_str(), entry.str().c_str());
50
return
true
;
51
}
52
}
// unnamed namespace
53
54
ROOT::Experimental::TLogManager
&
ROOT::Experimental::TLogManager::Get
()
55
{
56
static
TLogManager
instance(std::make_unique<TLogHandlerDefault>());
57
return
instance;
58
}
ROOT::Experimental::TLogEntry::fFuncName
std::string fFuncName
Definition:
TLogger.hxx:139
ROOT::Experimental::TLogHandler::Emit
virtual bool Emit(const TLogEntry &entry)=0
Emit a log entry.
ROOT::Experimental::TLogHandler::~TLogHandler
virtual ~TLogHandler()
Definition:
TLogger.cxx:23
ROOT::Experimental::TLogEntry::fFile
std::string fFile
Definition:
TLogger.hxx:138
TLogger.hxx
ROOT::Experimental::TLogManager
A TLogHandler that multiplexes diagnostics to different client TLogHandlers.
Definition:
TLogger.hxx:63
ROOT::Experimental::TLogEntry
A diagnostic, emitted by the TLogManager upon destruction of the TLogEntry.
Definition:
TLogger.hxx:135
ROOT::Experimental::TLogManager::Get
static TLogManager & Get()
Definition:
TLogger.cxx:54
TError.h
ROOT::Experimental::TLogEntry::fLine
int fLine
Definition:
TLogger.hxx:140
ROOT::Experimental::TLogHandler
Abstract TLogHandler base class.
Definition:
TLogger.hxx:45
ROOT::Experimental::TLogEntry::fLevel
ELogLevel fLevel
Definition:
TLogger.hxx:141
GetErrorHandler
ErrorHandlerFunc_t GetErrorHandler()
Returns the current error handler function.
Definition:
TError.cxx:116
ROOT::Experimental::ELogLevel::kFatal
ROOT::Experimental::TLogEntry::fGroup
std::string fGroup
Definition:
TLogger.hxx:137