Belle II Software development
DAQLogMessage.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include "daq/slc/database/DAQLogMessage.h"
9
10#include <daq/slc/base/Date.h>
11
12using namespace Belle2;
13
14DAQLogMessage::DAQLogMessage()
15{
16 m_date = Date().get();
17 m_nodename = "";
18 m_priority = 0;
19 m_message = "";
20 m_category = 13;
21 m_id = -1;
22}
23
24DAQLogMessage::DAQLogMessage(const std::string& nodename,
25 LogFile::Priority priority,
26 const std::string& message)
27{
28 m_date = Date().get();
29 m_nodename = nodename;
30 m_priority = (int)priority;
31 m_message = message;
32 m_category = 13;
33 m_id = -1;
34}
35
36DAQLogMessage::DAQLogMessage(const std::string& nodename,
37 LogFile::Priority priority,
38 const std::string& message,
39 const Date& date)
40{
41 m_date = date.get();
42 m_nodename = nodename;
43 m_priority = (int)priority;
44 m_message = message;
45 m_category = 13;
46 m_id = -1;
47}
48
49DAQLogMessage::DAQLogMessage(const std::string& nodename,
50 LogFile::Priority priority,
51 const std::string& category,
52 const std::string& message)
53{
54 m_date = Date().get();
55 m_nodename = nodename;
56 m_priority = (int)priority;
57 m_message = message;
58 setCategory(category);
59 m_id = -1;
60}
61
62DAQLogMessage::DAQLogMessage(const std::string& nodename,
63 LogFile::Priority priority,
64 int category,
65 const std::string& message)
66{
67 m_date = Date().get();
68 m_nodename = nodename;
69 m_priority = (int)priority;
70 m_message = message;
71 setCategory(category);
72 m_id = -1;
73}
74
75DAQLogMessage::DAQLogMessage(const std::string& nodename,
76 LogFile::Priority priority,
77 const std::string& category,
78 const std::string& message,
79 const Date& date)
80{
81 m_date = date.get();
82 m_nodename = nodename;
83 m_priority = (int)priority;
84 m_message = message;
85 setCategory(category);
86 m_id = -1;
87}
88
89DAQLogMessage::DAQLogMessage(const std::string& nodename,
90 LogFile::Priority priority,
91 int category,
92 const std::string& message,
93 const Date& date)
94{
95 m_date = date.get();
96 m_nodename = nodename;
97 m_priority = (int)priority;
98 m_message = message;
99 setCategory(category);
100 m_id = -1;
101}
102
103DAQLogMessage::DAQLogMessage(const DAQLogMessage& log)
104{
105 m_date = log.getDateInt();
106 m_nodename = log.getNodeName();
107 m_priority = log.getPriorityInt();
108 m_message = log.getMessage();
109 m_category = log.getCategory();
110 m_id = log.getId();
111}
112
113void DAQLogMessage::setPriority(LogFile::Priority priority)
114{
115 m_priority = (int)priority;
116}
117
118void DAQLogMessage::setNodeName(const std::string& name)
119{
120 m_nodename = name;
121}
122
123int DAQLogMessage::getCategory() const
124{
125 return m_category;
126}
127
128const std::string DAQLogMessage::getCategoryName() const
129{
130 switch (m_category) {
131 case 1: return "PXD";
132 case 2: return "SVD";
133 case 3: return "CDC";
134 case 4: return "TOP";
135 case 5: return "ARICH";
136 case 6: return "ECL";
137 case 7: return "KLM";
138 case 8: return "TRG";
139 case 9: return "TTD";
140 case 10: return "HLT";
141 case 11: return "HVC";
142 case 12: return "MON";
143 case 13: return "DAQ";
144 default: break;
145 }
146 return "";
147}
148
149void DAQLogMessage::setCategory(int category)
150{
151 m_category = category;
152}
153
154void DAQLogMessage::setCategory(const std::string& category)
155{
156 if (category == "PXD") {
157 m_category = 1;
158 } else if (category == "SVD") {
159 m_category = 2;
160 } else if (category == "CDC") {
161 m_category = 3;
162 } else if (category == "TOP") {
163 m_category = 4;
164 } else if (category == "ARICH") {
165 m_category = 5;
166 } else if (category == "ECL") {
167 m_category = 6;
168 } else if (category == "KLM") {
169 m_category = 7;
170 } else if (category == "TRG") {
171 m_category = 8;
172 } else if (category == "TTD") {
173 m_category = 9;
174 } else if (category == "HLT") {
175 m_category = 10;
176 } else if (category == "HVC") {
177 m_category = 11;
178 } else if (category == "MON") {
179 m_category = 12;
180 } else if (category == "DAQ") {
181 m_category = 13;
182 } else {
183 m_category = -1;
184 }
185}
186
187void DAQLogMessage::setMessage(const std::string& message)
188{
189 m_message = message;
190}
191
192void DAQLogMessage::setDate()
193{
194 setDate(Date());
195}
196
197void DAQLogMessage::setDate(int date)
198{
199 m_date = date;
200}
201
202void DAQLogMessage::setDate(const Date& date)
203{
204 m_date = date.get();
205}
206
207LogFile::Priority DAQLogMessage::getPriority() const
208{
209 return (LogFile::Priority) m_priority;
210}
211
212int DAQLogMessage::getPriorityInt() const
213{
214 return m_priority;
215}
216
217const std::string& DAQLogMessage::getNodeName() const
218{
219 return m_nodename;
220}
221
222const std::string& DAQLogMessage::getMessage() const
223{
224 return m_message;
225}
226
227int DAQLogMessage::getDateInt() const
228{
229 return m_date;
230}
231
232const Date DAQLogMessage::getDate() const
233{
234 return Date(m_date);
235}
236
237const std::string DAQLogMessage::getPriorityText() const
238{
239 switch (getPriority()) {
240 case LogFile::DEBUG: return "DEBUG";
241 case LogFile::INFO: return "INFO";
242 case LogFile::NOTICE: return "NOTICE";
243 case LogFile::WARNING: return "WARNING";
244 case LogFile::ERROR: return "ERROR";
245 case LogFile::FATAL: return "FATAL";
246 default:
247 break;
248 }
249 return "UNKNOWN";
250}
Abstract base class for different kinds of events.