Logo ROOT   6.12/07
Reference Guide
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
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 
48 {
49  static TLogManager instance(std::make_unique<TLogHandlerDefault>());
50  return instance;
51 }
virtual bool Emit(const TLogEntry &entry)=0
static TLogManager & Get()
Definition: TLogger.cxx:47
Abstract TLogHandler base class.
Definition: TLogger.hxx:45