Skip to content

Commit 4528885

Browse files
committed
Not sue InfoLogger for internal logging
1 parent 3c220f4 commit 4528885

File tree

10 files changed

+30
-31
lines changed

10 files changed

+30
-31
lines changed

src/Backends/ApMonBackend.cxx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ namespace Monitoring
1818
namespace Backends
1919
{
2020

21-
using AliceO2::InfoLogger::InfoLogger;
22-
2321
ApMonBackend::ApMonBackend(const std::string& configurationFile)
2422
{
2523
try {

src/Backends/Flume.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <string>
88
#include "../Transports/UDP.h"
99
#include <boost/property_tree/json_parser.hpp>
10+
#include <boost/lexical_cast.hpp>
1011

1112
namespace AliceO2
1213
{
@@ -17,8 +18,6 @@ namespace Monitoring
1718
namespace Backends
1819
{
1920

20-
using AliceO2::InfoLogger::InfoLogger;
21-
2221
Flume::Flume(const std::string &hostname, int port)
2322
{
2423
mTransport = std::make_unique<Transports::UDP>(hostname, port);

src/Backends/InfluxDB.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
///
55

66
#include "InfluxDB.h"
7+
#include <boost/lexical_cast.hpp>
78
#include <string>
89
#include "../Transports/UDP.h"
910
#include "../Transports/HTTP.h"
@@ -18,8 +19,6 @@ namespace Monitoring
1819
namespace Backends
1920
{
2021

21-
using AliceO2::InfoLogger::InfoLogger;
22-
2322
InfluxDB::InfluxDB(const std::string &hostname, int port)
2423
{
2524
transport = std::make_unique<Transports::UDP>(hostname, port);

src/Collector.cxx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ namespace Monitoring
3535

3636
Collector::Collector(const std::string& configPath)
3737
{
38-
MonLogger::Get() << AliceO2::InfoLogger::InfoLogger::Severity::Debug
39-
<< "Creating Monitoring instance from configuration: "
40-
<< configPath << MonLogger::End();
38+
MonLogger::Get() << "Creating Monitoring instance from configuration: "
39+
<< configPath << MonLogger::End();
4140

4241
std::unique_ptr<Configuration::ConfigurationInterface> configFile =
4342
Configuration::ConfigurationFactory::getConfiguration(configPath);

src/DerivedMetrics.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include "Monitoring/DerivedMetrics.h"
77
#include "Exceptions/MonitoringInternalException.h"
8-
8+
#include <boost/lexical_cast.hpp>
99
#include <chrono>
1010
#include <iostream>
1111
#include <map>

src/Exceptions/MonitoringException.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
///
55

66
#include "MonitoringException.h"
7+
#include <sstream>
78
#include "../MonLogger.h"
89

910
namespace AliceO2
@@ -20,7 +21,7 @@ MonitoringException::MonitoringException(int code, const std::string& source, co
2021
std::stringstream ss;
2122
ss << "MonitoringException[" << source << "] (" << code << "): " << message;
2223
this->message = ss.str();
23-
MonLogger::Get() << AliceO2::InfoLogger::InfoLogger::Severity::Error << message << MonLogger::End();
24+
MonLogger::Get() << message << MonLogger::End();
2425
}
2526

2627
const char* MonitoringException::what() const throw()

src/Exceptions/MonitoringInternalException.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ MonitoringInternalException::MonitoringInternalException(const std::string& sour
1818
MonitoringInternalException::MonitoringInternalException(int code, const std::string& source, const std::string& message)
1919
: message(message)
2020
{
21-
MonLogger::Get() << AliceO2::InfoLogger::InfoLogger::Severity::Debug << "MonitoringInternalException["
21+
MonLogger::Get() << "MonitoringInternalException["
2222
<< source << "] (" << code << "): " << message << MonLogger::End();
2323
}
2424

src/MonLogger.h

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,52 @@
11
///
22
/// \file MonLogger.h
3-
/// \author Barthelemy von Haller
43
/// \author Adam Wegrzynek <[email protected]>
54
///
65

76
#ifndef MONITORING_MONINFOLOGGER_H
87
#define MONITORING_MONINFOLOGGER_H
98

109
#include <iostream>
11-
#include <InfoLogger/InfoLogger.hxx>
1210

1311
namespace AliceO2
1412
{
1513
/// ALICE O2 Monitoring system
1614
namespace Monitoring
1715
{
1816

19-
using namespace AliceO2::InfoLogger;
20-
21-
/// Singleton class that is used in all Monitoring classes
22-
///
23-
/// The aim of this class is to avoid every class in the package to define and configure its own instance of InfoLogger.
24-
/// Independent InfoLogger instance can still be created when and if needed.
25-
class MonLogger : public AliceO2::InfoLogger::InfoLogger
17+
/// Simple Monitoring logging class
18+
class MonLogger
2619
{
2720
public:
21+
template <typename T>
22+
MonLogger &operator<<(const T &log) {
23+
mStream << log;
24+
return *this;
25+
}
26+
27+
MonLogger &operator<<(std::ostream& (*log) (std::ostream&)) {
28+
mStream << log;
29+
return *this;
30+
}
2831
static MonLogger &Get()
2932
{
30-
static MonLogger infoLoggerInstance;
31-
return infoLoggerInstance;
33+
static MonLogger loggerInstance;
34+
return loggerInstance;
3235
}
33-
static auto End() -> decltype(AliceO2::InfoLogger::InfoLogger::endm)
36+
static auto End() -> decltype("\n")
3437
{
35-
return AliceO2::InfoLogger::InfoLogger::endm;
38+
return "\n";
3639
}
3740

3841
private:
39-
MonLogger() = default;
42+
std::ostream &mStream;
43+
MonLogger(std::ostream &oStream = std::cout): mStream(oStream) {};
4044

4145
/// Delete copy and move constructors
4246
MonLogger &operator=(const MonLogger &) = delete;
4347
MonLogger(const MonLogger &) = delete;
4448
MonLogger(MonLogger &&) = delete;
45-
MonLogger &operator=(InfoLogger&&) = delete;
49+
MonLogger &operator=(MonLogger&&) = delete;
4650

4751
};
4852

src/MonitoringFactory.cxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ namespace AliceO2
1414
namespace Monitoring
1515
{
1616

17-
using AliceO2::InfoLogger::InfoLogger;
18-
1917
std::string MonitoringFactory::configPath = "";
2018

2119
void MonitoringFactory::Configure(const std::string& configPath)
@@ -25,8 +23,8 @@ void MonitoringFactory::Configure(const std::string& configPath)
2523
Configuration::ConfigurationFactory::getConfiguration(configPath);
2624
}
2725
else {
28-
MonLogger::Get() << InfoLogger::Severity::Warning << "Reconfiguration of Monitoring forebidden! Valid configuration path: "
29-
<< MonitoringFactory::configPath << MonLogger::End();
26+
MonLogger::Get() << "Reconfiguration of Monitoring forebidden! Valid configuration path: "
27+
<< MonitoringFactory::configPath << MonLogger::End();
3028
}
3129
}
3230

src/ProcessMonitor.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <boost/algorithm/string/split.hpp>
1010
#include <chrono>
1111
#include "MonLogger.h"
12+
#include <sstream>
1213

1314
namespace AliceO2
1415
{

0 commit comments

Comments
 (0)