mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / ndb / include / logger / SysLogHandler.hpp
blob163b9189275644b0494805674ed49cdaa81efe7b
1 /* Copyright (c) 2003-2005 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
16 #ifndef SYSLOGHANDLER_H
17 #define SYSLOGHANDLER_H
19 #include "LogHandler.hpp"
20 #ifndef NDB_WIN32
21 #include <syslog.h>
22 #endif
24 /**
25 * Logs messages to syslog. The default identity is 'NDB'.
26 * See 'man 3 syslog'.
28 * It logs the following severity levels.
29 * <pre>
31 * LOG_ALERT A condition that should be corrected
32 * immediately, such as a corrupted system
33 * database.
35 * LOG_CRIT Critical conditions, such as hard device
36 * errors.
38 * LOG_ERR Errors.
40 * LOG_WARNING Warning messages.
42 * LOG_INFO Informational messages.
44 * LOG_DEBUG Messages that contain information nor-
45 * mally of use only when debugging a pro-
46 * gram.
47 * </pre>
49 * @see LogHandler
50 * @version #@ $Id: SysLogHandler.hpp,v 1.2 2003/09/01 10:15:53 innpeno Exp $
52 class SysLogHandler : public LogHandler
54 public:
55 /**
56 * Default constructor.
58 SysLogHandler();
60 /**
61 * Create a new syslog handler with the specified identity.
63 * @param pIdentity a syslog identity.
64 * @param facility syslog facility, defaults to LOG_USER
66 SysLogHandler(const char* pIdentity, int facility);
68 /**
69 * Destructor.
71 virtual ~SysLogHandler();
73 virtual bool open();
74 virtual bool close();
76 virtual bool setParam(const BaseString &param, const BaseString &value);
77 bool setFacility(const BaseString &facility);
79 protected:
80 virtual void writeHeader(const char* pCategory, Logger::LoggerLevel level);
81 virtual void writeMessage(const char* pMsg);
82 virtual void writeFooter();
84 private:
85 /** Prohibit*/
86 SysLogHandler(const SysLogHandler&);
87 SysLogHandler operator = (const SysLogHandler&);
88 bool operator == (const SysLogHandler&);
90 int m_severity;
91 const char* m_pCategory;
93 /** Syslog identity for all log entries. */
94 const char* m_pIdentity;
95 int m_facility;
98 #endif