Logo ROOT   6.18/05
Reference Guide
RLogger.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/RLogger.hxx"
17#include <iostream>
18#include <sstream>
19
20#include "TError.h"
21
22// pin vtable
24
25namespace {
26class RLogHandlerDefault: public ROOT::Experimental::RLogHandler {
27public:
28 // Returns false if further emission of this log entry should be suppressed.
29 bool Emit(const ROOT::Experimental::RLogEntry &entry) override;
30};
31
32bool RLogHandlerDefault::Emit(const ROOT::Experimental::RLogEntry &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)],
49 strm.str().c_str(), entry.str().c_str());
50 return true;
51}
52} // unnamed namespace
53
55{
56 static RLogManager instance(std::make_unique<RLogHandlerDefault>());
57 return instance;
58}
ErrorHandlerFunc_t GetErrorHandler()
Returns the current error handler function.
Definition: TError.cxx:116
A diagnostic, emitted by the RLogManager upon destruction of the RLogEntry.
Definition: RLogger.hxx:136
Abstract RLogHandler base class.
Definition: RLogger.hxx:46
A RLogHandler that multiplexes diagnostics to different client RLogHandlers.
Definition: RLogger.hxx:64
static RLogManager & Get()
Definition: RLogger.cxx:54