Skip to content

Commit e0acf26

Browse files
committed
[alf] Assign Infologger error codes
1 parent 26eea1b commit e0acf26

File tree

8 files changed

+57
-19
lines changed

8 files changed

+57
-19
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,42 @@ It extends the `SCA_SEQUENCE` to add the following functionality:
237237
* DIM input ` `
238238
* DIM output ` `
239239

240+
## Logging
241+
Logging is achieved through the use of the [InfoLogger](https://github.com/AliceO2Group/InfoLogger) library.
242+
243+
Error codes in the range 5000-5999 are assigned to ALF. These are further partitioned according to components:
244+
245+
### General
246+
| 5000 - 5099 | Full Range |
247+
| ----------- | ---------- |
248+
249+
### DIM
250+
| 5100 - 5199 | Full Range |
251+
| ----------- | ---------- |
252+
253+
### SWT
254+
| 4200 - 4299 | Full Range |
255+
| ----------- | ---------- |
256+
257+
### SCA
258+
| 4300 - 4399 | Full Range |
259+
| ----------- | ---------- |
260+
261+
### IC
262+
| 4400 - 4499 | Full Range |
263+
| ----------- | ---------- |
264+
265+
### LLA
266+
| 4400 - 4499 | Full Range |
267+
| ----------- | ---------- |
268+
269+
### Unassigned
270+
| Range |
271+
| ----- |
272+
| 4500 - 4999 |
273+
274+
275+
240276
## Slow Control library
241277
ALF can also be used as a C++ library to access the Slow Control interface of the CRU. The three available interfaces (IC, SCA & SWT) can be accessed through single operations, or sequences of operations.
242278

apps/Alf.cxx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ class Alf : public AliceO2::Common::Program
7171
kDebugLogging = isVerbose();
7272

7373
Logger::setFacility("ALF");
74-
Logger::get() << "ALF server starting..." << LogInfoOps << endm;
74+
Logger::get() << "ALF server starting..." << LogInfoOps_(5000) << endm;
7575

7676
if (mOptions.dimDnsNode != "") {
77-
Logger::get() << "Setting DIM_DNS_NODE from argument." << LogDebugDevel << endm;
78-
Logger::get() << "DIM_DNS_NODE=" << mOptions.dimDnsNode << LogDebugDevel << endm;
77+
Logger::get() << "Setting DIM_DNS_NODE from argument." << LogDebugDevel_(5001) << endm;
78+
Logger::get() << "DIM_DNS_NODE=" << mOptions.dimDnsNode << LogDebugDevel_(5001) << endm;
7979
} else if (const char* dimDnsNode = std::getenv("DIM_DNS_NODE")) {
80-
Logger::get() << "Picked up DIM_DMS_NODE from the environment." << LogDebugDevel << endm;
81-
Logger::get() << "DIM_DNS_NODE=" << dimDnsNode << LogDebugDevel << endm;
80+
Logger::get() << "Picked up DIM_DMS_NODE from the environment." << LogDebugDevel_(5002) << endm;
81+
Logger::get() << "DIM_DNS_NODE=" << dimDnsNode << LogDebugDevel_(5002) << endm;
8282
mOptions.dimDnsNode = dimDnsNode;
8383
} else {
8484
BOOST_THROW_EXCEPTION(AlfException() << ErrorInfo::Message("DIM_DNS_NODE env variable not set, and no relevant argument provided.")); // InfoLogger and errors?
@@ -89,14 +89,14 @@ class Alf : public AliceO2::Common::Program
8989
try {
9090
swtWordSize = SwtWord::sizeFromString(mOptions.swtWordSize);
9191
} catch (const ParseException& e) {
92-
Logger::get() << e.what() << LogWarningOps << endm;
93-
Logger::get() << "SWT word size defaulting to low" << LogWarningOps << endm;
92+
Logger::get() << e.what() << LogWarningOps_(5003) << endm;
93+
Logger::get() << "SWT word size defaulting to low" << LogWarningOps_(5003) << endm;
9494
}
9595

9696
std::string alfId = ip::host_name();
9797
boost::to_upper(alfId);
9898

99-
Logger::get() << "Starting the DIM Server" << LogInfoDevel << endm;
99+
Logger::get() << "Starting the DIM Server" << LogInfoDevel_(5004) << endm;
100100
DimServer::setDnsNode(mOptions.dimDnsNode.c_str(), 2505);
101101
DimServer::start(("ALF_" + alfId).c_str());
102102

@@ -113,32 +113,32 @@ class Alf : public AliceO2::Common::Program
113113
try {
114114
roc::FirmwareChecker().checkFirmwareCompatibility(card.pciAddress);
115115
} catch (const roc::Exception& e) {
116-
Logger::get() << e.what() << LogWarningOps << endm;
116+
Logger::get() << e.what() << LogWarningOps_(5005) << endm;
117117
continue;
118118
}
119119
}
120120

121121
if (card.cardType == roc::CardType::Cru) {
122122

123-
Logger::get() << "CRU " << card.serialId << " registered" << LogInfoDevel << endm;
123+
Logger::get() << "CRU " << card.serialId << " registered" << LogInfoDevel_(5006) << endm;
124124
bar = roc::ChannelFactory().getBar(card.serialId, 2);
125125
for (int linkId = 0; linkId < kCruNumLinks; linkId++) {
126126
links.push_back({ alfId, card.serialId, linkId, card.serialId.getEndpoint() * 12 + linkId, bar, roc::CardType::Cru });
127127
}
128128

129129
} else if (card.cardType == roc::CardType::Crorc) {
130-
Logger::get() << "CRORC " << card.serialId << " registered" << LogInfoDevel << endm;
130+
Logger::get() << "CRORC " << card.serialId << " registered" << LogInfoDevel_(5007) << endm;
131131
for (int linkId = 0; linkId < kCrorcNumLinks; linkId++) {
132132
bar = roc::ChannelFactory().getBar(card.serialId, linkId);
133133
links.push_back({ alfId, card.serialId, linkId, -1, bar, roc::CardType::Crorc });
134134
}
135135
} else {
136-
Logger::get() << card.serialId << " is not a CRU or a CRORC. Skipping..." << LogWarningDevel << endm;
136+
Logger::get() << card.serialId << " is not a CRU or a CRORC. Skipping..." << LogWarningDevel_(5008) << endm;
137137
}
138138

139139
if (isVerbose()) {
140140
for (auto const& link : links) {
141-
Logger::get() << link.alfId << " " << link.serialId << " " << link.linkId << LogDebugDevel << endm;
141+
Logger::get() << link.alfId << " " << link.serialId << " " << link.linkId << LogDebugDevel_(5009) << endm;
142142
}
143143
}
144144
alfServer.makeRpcServers(links, mOptions.sequentialRpcs);

src/DimServices/DimServices.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void StringRpcServer::rpcHandler()
9595
setDataString(makeSuccessString(returnValue), *this);
9696
} catch (const std::exception& e) {
9797
if (kDebugLogging) {
98-
Logger::get() << mServiceName << ": " << e.what() << LogErrorDevel << endm;
98+
Logger::get() << mServiceName << ": " << e.what() << LogErrorDevel_(5100) << endm;
9999
}
100100
setDataString(makeFailureString(e.what()), *this);
101101
}

src/DimServices/DimServices.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ bool isSuccess(const std::string& str);
6666
bool isFailure(const std::string& str);
6767
std::string stripPrefix(const std::string& str);
6868

69+
// SERVER
6970
class StringRpcServer : public DimRpcParallel
7071
{
7172
public:
@@ -86,6 +87,7 @@ class StringRpcServer : public DimRpcParallel
8687
std::string mServiceName;
8788
};
8889

90+
// CLIENT
8991
class DimRpcInfoWrapper
9092
{
9193
public:
@@ -103,7 +105,7 @@ class DimRpcInfoWrapper
103105
{
104106
auto str = std::string(mRpcInfo->getString());
105107
if (isFailure(str) && kDebugLogging) {
106-
Logger::get() << "ALF server failure: " << str << LogErrorDevel << endm;
108+
Logger::get() << "ALF server failure: " << str << LogErrorDevel_(5101) << endm;
107109
}
108110
return str;
109111
}

src/Ic.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ std::string Ic::writeSequence(std::vector<std::pair<Operation, Data>> ops, bool
213213
std::string errMessage = boost::get<std::string>(data);
214214
resultBuffer << errMessage;
215215
if (kDebugLogging) {
216-
Logger::get() << errMessage << LogErrorDevel << endm;
216+
Logger::get() << errMessage << LogErrorDevel_(5400) << endm;
217217
}
218218
BOOST_THROW_EXCEPTION(IcException() << ErrorInfo::Message(resultBuffer.str()));
219219
}

src/Sca.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ std::string Sca::writeSequence(const std::vector<std::pair<Operation, Data>>& op
313313
} else if (operation == Operation::Error) {
314314
resultBuffer << data; // "[error_msg]"
315315
if (kDebugLogging) {
316-
Logger::get() << data << LogErrorDevel << endm;
316+
Logger::get() << data << LogErrorDevel_(5300) << endm;
317317
}
318318
BOOST_THROW_EXCEPTION(ScaException() << ErrorInfo::Message(resultBuffer.str()));
319319
break;

src/ScaMftPsu.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ std::string ScaMftPsu::writeSequence(const std::vector<std::pair<Operation, Data
329329
} else if (operation == Operation::Error) {
330330
resultBuffer << data; // "[error_msg]"
331331
if (kDebugLogging) {
332-
Logger::get() << data << LogErrorDevel << endm;
332+
Logger::get() << data << LogErrorDevel_(5301) << endm;
333333
}
334334
BOOST_THROW_EXCEPTION(ScaMftPsuException() << ErrorInfo::Message(resultBuffer.str()));
335335
break;

src/Swt.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ std::string Swt::writeSequence(std::vector<std::pair<Operation, Data>> sequence,
217217
} else if (operation == Operation::Error) {
218218
resultBuffer << data;
219219
if (kDebugLogging) {
220-
Logger::get() << data << LogErrorDevel << endm;
220+
Logger::get() << data << LogErrorDevel_(5200) << endm;
221221
}
222222
BOOST_THROW_EXCEPTION(SwtException() << ErrorInfo::Message(resultBuffer.str()));
223223
break;

0 commit comments

Comments
 (0)