1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Mark Atwood
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30
# define SYSLOG_NAMES 1
34
namespace drizzle_plugin
37
WrapSyslog::WrapSyslog () :
41
WrapSyslog::~WrapSyslog ()
47
/* TODO, for the sake of performance, scan through all the priority
48
and facility names, and construct a stl hash, minimal perfect hash,
49
or some other high performance read data structure. This can even
50
be done at compile time. */
52
int WrapSyslog::getPriorityByName(const char *priority_name)
54
for (int ndx= 0; prioritynames[ndx].c_name; ndx++)
56
if (strcasecmp(prioritynames[ndx].c_name, priority_name) == 0)
58
return prioritynames[ndx].c_val;
61
// no matching priority found
65
int WrapSyslog::getFacilityByName(const char *facility_name)
67
for (int ndx= 0; facilitynames[ndx].c_name; ndx++)
69
if (strcasecmp(facilitynames[ndx].c_name, facility_name) == 0)
71
return facilitynames[ndx].c_val;
74
// no matching facility found
78
void WrapSyslog::openlog(const std::string &ident)
82
::openlog(ident.c_str(), LOG_PID, LOG_USER);
87
void WrapSyslog::vlog(int facility, int priority, const char *format, va_list ap)
89
assert(_check == true);
90
vsyslog(facility | priority, format, ap);
93
void WrapSyslog::log (int facility, int priority, const char *format, ...)
95
assert(_check == true);
98
vsyslog(facility | priority, format, ap);
102
} /* namespace drizzle_plugin */