-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogging.cpp
More file actions
46 lines (35 loc) · 783 Bytes
/
logging.cpp
File metadata and controls
46 lines (35 loc) · 783 Bytes
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
#include <iostream>
#include <memory>
#include <vector>
#include "logging.h"
namespace schrandr {
Logger::Logger():
syslog_(false)
{}
Logger::~Logger()
{
log("Closing log and exiting");
if (syslog_) closelog();
}
void Logger::enable_syslog()
{
openlog("schrandr", LOG_CONS, LOG_USER);
syslog_ = true;
}
void Logger::log(const std::string &msg)
{
syslog(LOG_INFO, msg.c_str());
}
void Logger::log(char* msg)
{
syslog(LOG_INFO, msg);
}
void Logger::log(int level, const std::string &msg)
{
syslog(level, msg.c_str());
}
void Logger::log(int level, char* msg)
{
syslog(level, msg);
}
}