-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathSysLogs.cpp
47 lines (38 loc) · 977 Bytes
/
SysLogs.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
/**
* SysLog.cpp
*
* Rewritten / author: 2016-02-19 / mrmisticismo@hotmail.com
* Published / author: 2005-08-12 / grymse@alhem.net
* Copyright (C) 2015-2019 Michael Griffin
* Copyright (C) 2001-2006 Anders Hedstrom
* This program is made available under the terms of the GNU GPL.
*/
#ifndef _WIN32
#include <sqlite3.h>
#include <syslog.h>
#include "Database.h"
#include "Query.h"
#include "IError.h"
#include "SysLogs.h"
namespace SQLW
{
SysLog::SysLog(const std::string& appname,int option,int facility)
{
openlog(appname.c_str(), option, facility);
}
SysLog::~SysLog()
{
closelog();
}
void SysLog::databaseError(Database& db,const std::string& str)
{
if(!db.isConnected())
syslog(LOG_ERR, "%s", str.c_str());
}
void SysLog::databaseError(Database& db,Query& q,const std::string& str)
{
if(!db.isConnected())
syslog(LOG_ERR, "QUERY: \"%s\" : %s", q.getLastQuery().c_str(), str.c_str());
}
} // namespace SQLW
#endif // WIN32