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>
40 void LogListener::run()
47 LogFile::Priority priority = LogFile::UNKNOWN;
51 c = preader.readChar();
53 if (c !=
'\n' && iscntrl(c))
continue;
55 if (c ==
'\n' && count > 0) {
56 std::string assembledLogMessage(ss.str());
62 if (m_enableUnescapeNewlines) {
63 assembledLogMessage = StringUtil::replace(assembledLogMessage,
"\\n",
"\n");
66 s = m_con->getParName() +
" : " + assembledLogMessage;
69 if (priority == LogFile::UNKNOWN) {
70 priority = LogFile::DEBUG;
73 if (priority > LogFile::DEBUG) {
74 m_con->getCallback()->log(priority, s);
79 if (m_con->getCallback()->getNode().getState() == RCState::RUNNING_S) {
80 if (priority == LogFile::ERROR) {
82 }
else if (priority == LogFile::FATAL) {
84 m_con->getCallback()->setState(RCState::ERROR_ES);
89 priority = LogFile::UNKNOWN;
90 }
else if (isprint(c)) {
91 if (count == 0 && c ==
'[') {
94 c = preader.readChar();
98 if (s ==
"[DEBUG]") priority = LogFile::DEBUG;
99 else if (s ==
"[INFO]") priority = LogFile::INFO;
100 else if (s ==
"[NOTICE]") priority = LogFile::NOTICE;
101 else if (s ==
"[WARNING]") priority = LogFile::WARNING;
102 else if (s ==
"[ERROR]") priority = LogFile::ERROR;
103 else if (s ==
"[FATAL]") priority = LogFile::FATAL;
104 else if (s.find(
"STOP") != std::string::npos) {
105 StringList sl = StringUtil::split(s,
'=');
107 std::string nodename = StringUtil::replace(sl[1],
"]",
"");
110 }
catch (
const std::exception& e) {
121 priority = LogFile::DEBUG;
128 if (c !=
' ' || count > 0) {
136 LogFile::debug(e.what());
138 s = m_con->getParName() +
" : " + ss.str();
141 if (priority == LogFile::UNKNOWN) {
142 priority = LogFile::DEBUG;
144 m_con->getCallback()->log(priority, s);
145 if (m_con->getCallback()->getNode().getState() == RCState::RUNNING_S) {
146 if (priority == LogFile::ERROR) {
148 }
else if (priority == LogFile::FATAL) {
150 m_con->getCallback()->setState(RCState::ERROR_ES);
Abstract base class for different kinds of events.