Skip to content

Commit a5dbb75

Browse files
committed
Fix fetching runNr / partition ID, cut log file name to 32 characters since otherwise infologger bails out...
1 parent 9e808c7 commit a5dbb75

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

Utilities/EPNMonitoring/src/EPNstderrMonitor.cxx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class EPNMonitor
5858
public:
5959
EPNMonitor(std::string path, bool infoLogger, int runNumber, std::string partition);
6060
~EPNMonitor();
61+
void setRunNr(int nr) { mRunNUmber = nr; }
6162

6263
private:
6364
void thread();
@@ -90,7 +91,6 @@ EPNMonitor::EPNMonitor(std::string path, bool infoLogger, int runNumber, std::st
9091
mLogger = std::make_unique<InfoLogger::InfoLogger>();
9192
mLoggerContext = std::make_unique<InfoLogger::InfoLoggerContext>();
9293
mLoggerContext->setField(InfoLogger::InfoLoggerContext::FieldName::Partition, partition != "" ? partition : "unspecified");
93-
mLoggerContext->setField(InfoLogger::InfoLoggerContext::FieldName::Run, runNumber == 0 ? std::to_string(runNumber) : "unspecified");
9494
mLoggerContext->setField(InfoLogger::InfoLoggerContext::FieldName::System, std::string("STDERR"));
9595
}
9696
mThread = std::thread(&EPNMonitor::thread, this);
@@ -114,7 +114,8 @@ void EPNMonitor::check_add_file(const std::string& filename)
114114
void EPNMonitor::sendLog(const std::string& file, const std::string& message)
115115
{
116116
if (mInfoLoggerActive) {
117-
mLoggerContext->setField(InfoLogger::InfoLoggerContext::FieldName::Facility, "stderr/" + file);
117+
mLoggerContext->setField(InfoLogger::InfoLoggerContext::FieldName::Facility, ("stderr/" + file).substr(0, 31));
118+
mLoggerContext->setField(InfoLogger::InfoLoggerContext::FieldName::Run, mRunNUmber == 0 ? std::to_string(mRunNUmber) : "unspecified");
118119
static const InfoLogger::InfoLogger::InfoLoggerMessageOption opt = {InfoLogger::InfoLogger::Severity::Error, 3, InfoLogger::InfoLogger::undefinedMessageOption.errorCode, InfoLogger::InfoLogger::undefinedMessageOption.sourceFile, InfoLogger::InfoLogger::undefinedMessageOption.sourceLine};
119120
mLogger->log(opt, *mLoggerContext, "stderr: %s", message.c_str());
120121
} else {
@@ -222,14 +223,23 @@ struct EPNstderrMonitor : fair::mq::Device {
222223
std::string path = ".";
223224
bool infoLogger = fConfig->GetProperty<int>("infologger");
224225
bool dds = false;
225-
/* if (fConfig->Count("plugin")) {
226-
const auto& plugins = fConfig->GetProperty<std::vector<std::string>>("plugin");
227-
dds = std::find(plugins.begin(), plugins.end(), "ODC") != plugins.end();
226+
227+
std::string partition = "";
228+
try {
229+
fConfig->GetProperty<std::string>("environment_id", "");
230+
} catch (...) {
228231
}
229-
int runNumber = dds ? atoi(fConfig->GetProperty<std::string>("runNumber").c_str()) : 0;*/
232+
233+
gEPNMonitor = std::make_unique<EPNMonitor>(path, infoLogger, 0, partition);
234+
}
235+
void PreRun() override
236+
{
230237
int runNumber = 0;
231-
std::string partition = "";
232-
gEPNMonitor = std::make_unique<EPNMonitor>(path, infoLogger, runNumber, partition);
238+
try {
239+
runNumber = atoi(fConfig->GetProperty<std::string>("runNumber", "").c_str());
240+
} catch (...) {
241+
}
242+
gEPNMonitor->setRunNr(runNumber);
233243
}
234244
bool ConditionalRun() override
235245
{

0 commit comments

Comments
 (0)