8#include "daq/slc/readout/LogListener.h"
10#include "daq/slc/readout/ProcessController.h"
12#include <daq/slc/runcontrol/RCCallback.h>
13#include <daq/slc/runcontrol/RCCommand.h>
14#include <daq/slc/nsm/NSMCommunicator.h>
16#include <daq/slc/system/File.h>
17#include <daq/slc/system/FileReader.h>
19#include <daq/slc/base/IOException.h>
20#include <daq/slc/base/StringUtil.h>
21#include <daq/slc/system/LogFile.h>
40void LogListener::run()
46 LogFile::Priority priority = LogFile::UNKNOWN;
50 int c = preader.readChar();
52 if (c !=
'\n' && iscntrl(c))
continue;
54 if (c ==
'\n' && count > 0) {
55 std::string assembledLogMessage(ss.str());
61 if (m_enableUnescapeNewlines) {
62 assembledLogMessage = StringUtil::replace(assembledLogMessage,
"\\n",
"\n");
65 s = m_con->getParName() +
" : " + assembledLogMessage;
68 if (priority == LogFile::UNKNOWN) {
69 priority = LogFile::DEBUG;
72 if (priority > LogFile::DEBUG) {
73 m_con->getCallback()->log(priority, s);
78 if (m_con->getCallback()->getNode().getState() == RCState::RUNNING_S) {
79 if (priority == LogFile::ERROR) {
81 }
else if (priority == LogFile::FATAL) {
83 m_con->getCallback()->setState(RCState::ERROR_ES);
88 priority = LogFile::UNKNOWN;
89 }
else if (isprint(c)) {
90 if (count == 0 && c ==
'[') {
93 c = preader.readChar();
97 if (s ==
"[DEBUG]") priority = LogFile::DEBUG;
98 else if (s ==
"[INFO]") priority = LogFile::INFO;
99 else if (s ==
"[NOTICE]") priority = LogFile::NOTICE;
100 else if (s ==
"[WARNING]") priority = LogFile::WARNING;
101 else if (s ==
"[ERROR]") priority = LogFile::ERROR;
102 else if (s ==
"[FATAL]") priority = LogFile::FATAL;
103 else if (s.find(
"STOP") != std::string::npos) {
104 StringList sl = StringUtil::split(s,
'=');
106 std::string nodename = StringUtil::replace(sl[1],
"]",
"");
109 }
catch (
const std::exception& e) {
120 priority = LogFile::DEBUG;
127 if (c !=
' ' || count > 0) {
135 LogFile::debug(e.what());
137 s = m_con->getParName() +
" : " + ss.str();
140 if (priority == LogFile::UNKNOWN) {
141 priority = LogFile::DEBUG;
143 m_con->getCallback()->log(priority, s);
144 if (m_con->getCallback()->getNode().getState() == RCState::RUNNING_S) {
145 if (priority == LogFile::ERROR) {
147 }
else if (priority == LogFile::FATAL) {
149 m_con->getCallback()->setState(RCState::ERROR_ES);
Abstract base class for different kinds of events.