Skip to content

Commit a8ebf15

Browse files
committed
[alf] Disable debug logging by default
1 parent bd66b65 commit a8ebf15

File tree

12 files changed

+86
-27
lines changed

12 files changed

+86
-27
lines changed

apps/Alf.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class Alf : public AliceO2::Common::Program
6565

6666
virtual void run(const po::variables_map&) override
6767
{
68-
//verbose = isVerbose();
68+
kDebugLogging = isVerbose();
6969

7070
Logger::setFacility("ALF");
7171
Logger::get() << "ALF server starting..." << LogInfoOps << endm;

apps/AlfClient.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ class AlfClient : public AliceO2::Common::Program
101101

102102
virtual void run(const po::variables_map&) override
103103
{
104+
kDebugLogging = isVerbose();
105+
104106
Logger::enableInfoLogger(false);
105107
Logger::setFacility("ALF/Client");
106108
if (mOptions.alfId == "") {

apps/AlfLibClient.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class AlfLibClient : public AliceO2::Common::Program
6565

6666
virtual void run(const po::variables_map&) override
6767
{
68+
kDebugLogging = isVerbose();
69+
6870
Logger::enableInfoLogger(false);
6971
Logger::setFacility("ALF/LibClient");
7072
if (mOptions.sca) {

src/AlfClient.h

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ class RegisterReadRpc : DimRpcInfoWrapper
5252
toConvert = stripPrefix(getString());
5353
converted = Util::stringToHex(toConvert);
5454
} catch (const AlfException& e) {
55-
Logger::get() << "RegisterReadRpc: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
55+
if (kDebugLogging) {
56+
Logger::get() << "RegisterReadRpc: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
57+
}
5658
return errHex;
5759
}
5860

@@ -74,7 +76,9 @@ class RegisterWriteRpc : DimRpcInfoWrapper
7476
try {
7577
getString();
7678
} catch (const AlfException& e) {
77-
Logger::get() << "RegisterWriteRpc: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
79+
if (kDebugLogging) {
80+
Logger::get() << "RegisterWriteRpc: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
81+
}
7882
}
7983
}
8084
};
@@ -93,7 +97,9 @@ class PatternPlayerRpc : DimRpcInfoWrapper
9397
try {
9498
ret = getString();
9599
} catch (const AlfException& e) {
96-
Logger::get() << "PatternPlayerRpc: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
100+
if (kDebugLogging) {
101+
Logger::get() << "PatternPlayerRpc: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
102+
}
97103
return errString;
98104
}
99105
return ret;
@@ -127,7 +133,9 @@ class ScaSequenceRpc : DimRpcInfoWrapper
127133
try {
128134
ret = getString();
129135
} catch (const AlfException& e) {
130-
Logger::get() << "ScaSequence: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
136+
if (kDebugLogging) {
137+
Logger::get() << "ScaSequence: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
138+
}
131139
return errString;
132140
}
133141
return ret;
@@ -165,7 +173,9 @@ class RegisterSequenceRpc : DimRpcInfoWrapper
165173
try {
166174
ret = getString();
167175
} catch (const AlfException& e) {
168-
Logger::get() << "RegisterSequence: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
176+
if (kDebugLogging) {
177+
Logger::get() << "RegisterSequence: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
178+
}
169179
return errString;
170180
}
171181
return ret;
@@ -203,7 +213,9 @@ class SwtSequenceRpc : DimRpcInfoWrapper
203213
try {
204214
ret = getString();
205215
} catch (const AlfException& e) {
206-
Logger::get() << "SwtSequence: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
216+
if (kDebugLogging) {
217+
Logger::get() << "SwtSequence: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
218+
}
207219
return errString;
208220
}
209221
return ret;
@@ -241,7 +253,9 @@ class IcSequenceRpc : DimRpcInfoWrapper
241253
try {
242254
ret = getString();
243255
} catch (const AlfException& e) {
244-
Logger::get() << "IcSequence: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
256+
if (kDebugLogging) {
257+
Logger::get() << "IcSequence: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
258+
}
245259
return errString;
246260
}
247261
return ret;
@@ -278,7 +292,9 @@ class IcGbtI2cWriteRpc : DimRpcInfoWrapper
278292
try {
279293
getString();
280294
} catch (const AlfException& e) {
281-
Logger::get() << "IcGbtI2cWriteRpc: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
295+
if (kDebugLogging) {
296+
Logger::get() << "IcGbtI2cWriteRpc: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
297+
}
282298
}
283299
}
284300
};
@@ -298,7 +314,9 @@ class LlaSessionStartRpc : DimRpcInfoWrapper
298314
try {
299315
ret = getString();
300316
} catch (const AlfException& e) {
301-
Logger::get() << "LlaSessionStart: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
317+
if (kDebugLogging) {
318+
Logger::get() << "LlaSessionStart: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
319+
}
302320
return errString;
303321
}
304322
return ret;
@@ -331,7 +349,9 @@ class LlaSessionStopRpc : DimRpcInfoWrapper
331349
try {
332350
ret = getString();
333351
} catch (const AlfException& e) {
334-
Logger::get() << "LlaSessionStop: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
352+
if (kDebugLogging) {
353+
Logger::get() << "LlaSessionStop: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
354+
}
335355
return errString;
336356
}
337357
return ret;

src/DimServices/DimServices.cxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ void StringRpcServer::rpcHandler()
9494
auto returnValue = mCallback(std::string(getString()));
9595
setDataString(makeSuccessString(returnValue), *this);
9696
} catch (const std::exception& e) {
97-
Logger::get() << mServiceName << ": " << e.what() << LogErrorDevel << endm;
97+
if (kDebugLogging) {
98+
Logger::get() << mServiceName << ": " << e.what() << LogErrorDevel << endm;
99+
}
98100
setDataString(makeFailureString(e.what()), *this);
99101
}
100102
}

src/DimServices/DimServices.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class DimRpcInfoWrapper
102102
std::string getString()
103103
{
104104
auto str = std::string(mRpcInfo->getString());
105-
if (isFailure(str)) {
105+
if (isFailure(str) && kDebugLogging) {
106106
Logger::get() << "ALF server failure: " << str << LogErrorDevel << endm;
107107
}
108108
return str;

src/Ic.cxx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ namespace alf
4848
Ic::Ic(AlfLink link, std::shared_ptr<lla::Session> llaSession)
4949
: ScBase(link, llaSession)
5050
{
51-
Logger::setFacility("ALF/IC");
51+
if (kDebugLogging) {
52+
Logger::setFacility("ALF/IC");
53+
}
5254

5355
// Set CFG to 0x3 by default
5456
barWrite(sc_regs::IC_WR_CFG.index, 0x3);
@@ -57,7 +59,9 @@ Ic::Ic(AlfLink link, std::shared_ptr<lla::Session> llaSession)
5759
Ic::Ic(const roc::Parameters::CardIdType& cardId, int linkId)
5860
: ScBase(cardId, linkId)
5961
{
60-
Logger::setFacility("ALF/IC");
62+
if (kDebugLogging) {
63+
Logger::setFacility("ALF/IC");
64+
}
6165

6266
// Set CFG to 0x3 by default
6367
barWrite(sc_regs::IC_WR_CFG.index, 0x3);
@@ -66,7 +70,9 @@ Ic::Ic(const roc::Parameters::CardIdType& cardId, int linkId)
6670
Ic::Ic(std::string cardId, int linkId)
6771
: ScBase(cardId, linkId)
6872
{
69-
Logger::setFacility("ALF/IC");
73+
if (kDebugLogging) {
74+
Logger::setFacility("ALF/IC");
75+
}
7076

7177
// Set CFG to 0x3 by default
7278
barWrite(sc_regs::IC_WR_CFG.index, 0x3);
@@ -204,7 +210,9 @@ std::string Ic::writeSequence(std::vector<std::pair<Operation, Data>> ops, bool
204210
} else if (operation == Operation::Error) {
205211
std::string errMessage = boost::get<std::string>(data);
206212
resultBuffer << errMessage;
207-
Logger::get() << errMessage << LogErrorDevel << endm;
213+
if (kDebugLogging) {
214+
Logger::get() << errMessage << LogErrorDevel << endm;
215+
}
208216
BOOST_THROW_EXCEPTION(IcException() << ErrorInfo::Message(resultBuffer.str()));
209217
}
210218
}

src/Logger.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@
2323
typedef AliceO2::roc::Logger Logger;
2424
constexpr auto endm = AliceO2::roc::endm;
2525

26+
extern bool kDebugLogging;
27+
2628
#endif // O2_ALF_LOGGER_H_

src/ScBase.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
#include "Logger.h"
3333
#include "Util.h"
3434

35+
// hijacking this file to define an extern variable for the Logger
36+
bool kDebugLogging;
37+
3538
namespace sc_regs = AliceO2::roc::Cru::ScRegisters;
3639

3740
namespace o2

src/Sca.cxx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,25 @@ namespace alf
4343
Sca::Sca(AlfLink link, std::shared_ptr<lla::Session> llaSession)
4444
: ScBase(link, llaSession)
4545
{
46-
Logger::setFacility("ALF/SCA");
46+
if (kDebugLogging) {
47+
Logger::setFacility("ALF/SCA");
48+
}
4749
}
4850

4951
Sca::Sca(const roc::Parameters::CardIdType& cardId, int linkId)
5052
: ScBase(cardId, linkId)
5153
{
52-
Logger::setFacility("ALF/SCA");
54+
if (kDebugLogging) {
55+
Logger::setFacility("ALF/SCA");
56+
}
5357
}
5458

5559
Sca::Sca(std::string cardId, int linkId)
5660
: ScBase(cardId, linkId)
5761
{
58-
Logger::setFacility("ALF/SCA");
62+
if (kDebugLogging) {
63+
Logger::setFacility("ALF/SCA");
64+
}
5965
}
6066

6167
void Sca::svlReset()
@@ -304,7 +310,9 @@ std::string Sca::writeSequence(const std::vector<std::pair<Operation, Data>>& op
304310
resultBuffer << "svl_connect\n"; // echo
305311
} else if (operation == Operation::Error) {
306312
resultBuffer << data; // "[error_msg]"
307-
Logger::get() << data << LogErrorDevel << endm;
313+
if (kDebugLogging) {
314+
Logger::get() << data << LogErrorDevel << endm;
315+
}
308316
BOOST_THROW_EXCEPTION(ScaException() << ErrorInfo::Message(resultBuffer.str()));
309317
break;
310318
}

0 commit comments

Comments
 (0)