Logo ROOT   6.08/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 is welcome!
6 
7 /*************************************************************************
8  * Copyright (C) 1995-2015, Rene Brun and Fons Rademakers. *
9  * All rights reserved. *
10  * *
11  * For the licensing terms see $ROOTSYS/LICENSE. *
12  * For the list of contributors see $ROOTSYS/README/CREDITS. *
13  *************************************************************************/
14 
15 #include "ROOT/TLogger.hxx"
16 #include <iostream>
17 
18 // pin vtable
20 
21 namespace {
22 class TLogHandlerDefault: public ROOT::Experimental::TLogHandler {
23 public:
24  // Returns false if further emission of this log entry should be suppressed.
25  bool Emit(const ROOT::Experimental::TLogEntry &entry) override;
26 };
27 
28 bool TLogHandlerDefault::Emit(const ROOT::Experimental::TLogEntry &entry) {
29  constexpr static std::array<const char *, 5> sTag{
30  {"Debug",
31  "Info",
32  "Warning",
33  "Log",
34  "FATAL"}
35  };
36  std::cerr << "ROOT ";
37  if (!entry.fGroup.empty())
38  std::cerr << '[' << entry.fGroup << "] ";
39  std::cerr << sTag[static_cast<int>(entry.fLevel)];
40 
41  if (!entry.fFile.empty())
42  std::cerr << " " << entry.fFile << ':' << entry.fLine;
43  if (!entry.fFuncName.empty())
44  std::cerr << " in " << entry.fFuncName;
45  std::cerr << ":\n" << " " << entry.str();
46  return true;
47 }
48 } // unnamed namespace
49 
51  static TLogManager instance(std::make_unique<TLogHandlerDefault>());
52  return instance;
53 }
virtual bool Emit(const TLogEntry &entry)=0
static TLogManager & Get()
Definition: TLogger.cxx:50
Abstract TLogHandler base class.
Definition: TLogger.hxx:45
if(line.BeginsWith("/*"))
Definition: HLFactory.cxx:443