forked from suikan4github/murasaki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
murasaki_syslog.cpp
54 lines (42 loc) · 1.38 KB
/
murasaki_syslog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* murasaki_syslog.cpp
*
* Created on: 2018/09/02
* Author: takemasa
*/
#include "murasaki_syslog.hpp"
namespace murasaki {
// mask for the Syslog facility check
static uint32_t facility_mask = 0xFFFFFFFF;
// threshold for the Syslog severity check
static murasaki::SyslogSeverity severity_threashold = murasaki::kseError;
void SetSyslogSererityThreshold(murasaki::SyslogSeverity severity) {
severity_threashold = severity;
}
void SetSyslogFacilityMask(uint32_t mask) {
facility_mask = mask;
}
void AddSyslogFacilityToMask(murasaki::SyslogFacility facility) {
// set one the corresponding bit position
facility_mask |= facility;
}
void RemoveSyslogFacilityFromMask(murasaki::SyslogFacility facility) {
// set zero the corresponding bit position
facility_mask &= ~facility;
}
bool AllowedSyslogOut(murasaki::SyslogFacility facility,
murasaki::SyslogSeverity severity) {
// if severe than Error, always output
// note : lower the enum order is the higher severity
if (severity <= murasaki::kseError)
return true;
// or if severe than the threshold and allowed by facility mask, output
// note : lower the enum order is the higher severity
else if ((severity <= severity_threashold) &&
(facility & facility_mask))
return true;
// otherwise, not allowed
else
return false;
}
}