Belle II Software development
Debug.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <iostream>
10#include "trg/trg/Debug.h"
11
12using namespace std;
13
14namespace Belle2 {
20 vector<string> TRGDebug::_stages;
21 int TRGDebug::_level = 0;
22
23 void
24 TRGDebug::enterStage(const string& name)
25 {
26 if (_level)
27 cout << tab() << "--> ";
28 _stages.push_back(name);
29 if (_level)
30 cout << name << endl;
31 }
32
33 void
34 TRGDebug::leaveStage(const string& name)
35 {
36 if (name != _stages.back()) {
37 cout << "TRGDebug !!! given stage name(" << name << ") doesn't match"
38 << " to expected stage name(" << _stages.back() << endl;
39 return;
40 }
41 _stages.pop_back();
42 if (_level)
43 cout << tab() << "<-- " << name << endl;
44 }
45
46 string
48 {
49 string t;
50 const unsigned n = _stages.size();
51 for (unsigned i = 0; i < n; i++)
52 t += " ";
53 return t;
54 }
55
56 string
57 TRGDebug::tab(int extra)
58 {
59 string t = tab();
60 if (extra > 0)
61 for (unsigned i = 0; i < unsigned(extra); i++)
62 t += " ";
63 return t;
64 }
65
66 int
68 {
69 return _level;
70 }
71
72 int
73 TRGDebug::level(int a, bool b)
74 {
75 if (! b)
76 return _level = a;
77 else
78 return _level = a;
79 }
80
82} // namespace Belle2
83
static std::string tab(void)
returns tab spaces.
Definition: Debug.cc:47
static void enterStage(const std::string &stageName)
Declare that you enter new stage.
Definition: Debug.cc:24
static std::vector< std::string > _stages
Storage for stages.
Definition: Debug.h:47
static int _level
Debug level. 0:do nothing, 1:show you flow, 2:show you detail, 10:show you very detail.
Definition: Debug.h:50
static int level(void)
returns the debug level.
Definition: Debug.cc:67
static void leaveStage(const std::string &stageName)
Declare that you leave a stage.
Definition: Debug.cc:34
Abstract base class for different kinds of events.
STL namespace.