ROOT
6.12/07
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
19
// pin vtable
20
ROOT::Experimental::TLogHandler::~TLogHandler
() {}
21
22
namespace
{
23
class
TLogHandlerDefault:
public
ROOT::Experimental::TLogHandler
{
24
public
:
25
// Returns false if further emission of this log entry should be suppressed.
26
bool
Emit
(
const
ROOT::Experimental::TLogEntry
&entry)
override
;
27
};
28
29
bool
TLogHandlerDefault::Emit(
const
ROOT::Experimental::TLogEntry
&entry)
30
{
31
constexpr
static
std::array<const char *, 5> sTag{{
"Debug"
,
"Info"
,
"Warning"
,
"Log"
,
"FATAL"
}};
32
std::cerr <<
"ROOT "
;
33
if
(!entry.
fGroup
.empty())
34
std::cerr <<
'['
<< entry.
fGroup
<<
"] "
;
35
std::cerr << sTag[static_cast<int>(entry.
fLevel
)];
36
37
if
(!entry.
fFile
.empty())
38
std::cerr <<
" "
<< entry.
fFile
<<
':'
<< entry.
fLine
;
39
if (!entry.
fFuncName
.empty())
40
std::cerr <<
" in "
<< entry.
fFuncName
;
41
std::cerr <<
":\n"
42
<<
" "
<< entry.str() <<
'\n'
;
43
return
true
;
44
}
45
}
// unnamed namespace
46
47
ROOT::Experimental::TLogManager
&
ROOT::Experimental::TLogManager::Get
()
48
{
49
static
TLogManager
instance(std::make_unique<TLogHandlerDefault>());
50
return
instance;
51
}
ROOT::Experimental::TLogEntry::fFuncName
std::string fFuncName
Definition:
TLogger.hxx:83
ROOT::Experimental::TLogHandler::Emit
virtual bool Emit(const TLogEntry &entry)=0
ROOT::Experimental::TLogHandler::~TLogHandler
virtual ~TLogHandler()
Definition:
TLogger.cxx:20
ROOT::Experimental::TLogEntry::fFile
std::string fFile
Definition:
TLogger.hxx:82
TLogger.hxx
ROOT::Experimental::TLogManager
Definition:
TLogger.hxx:52
ROOT::Experimental::TLogEntry
Definition:
TLogger.hxx:79
ROOT::Experimental::TLogManager::Get
static TLogManager & Get()
Definition:
TLogger.cxx:47
ROOT::Experimental::TLogEntry::fLine
int fLine
Definition:
TLogger.hxx:84
ROOT::Experimental::TLogHandler
Abstract TLogHandler base class.
Definition:
TLogger.hxx:45
ROOT::Experimental::TLogEntry::fLevel
ELogLevel fLevel
Definition:
TLogger.hxx:85
ROOT::Experimental::TLogEntry::fGroup
std::string fGroup
Definition:
TLogger.hxx:81