![]() |
Main Page
Class Hierarchy
Alphabetical List
Compound List
File List
Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * Unix Syslog interface * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2003 by Mathew Robertson. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 *********************************************************************************/ 00022 #ifndef FXSYSTEMLOGGER_H 00023 #define FXSYSTEMLOGGER_H 00024 00025 #ifndef FXOBJECT_H 00026 #include <fox/FXObject.h> 00027 using namespace FX; 00028 #endif 00029 namespace FXEX { 00030 00031 /// a simple set of defines used to simplify the system logging syntax 00032 /// - takes FXString's, FXchar*'s or FXException's 00033 #ifndef NDEBUG 00034 # define SYSLOG(msg) FXSystemLogger::instance().log((msg)) 00035 # define SYSALERT(msg) FXSystemLogger::instance().alert(FXSystemLogger::PRI_ALERT,(msg)) 00036 # define SYSWRN(msg) FXSystemLogger::instance().warn(FXSystemLogger::PRI_WARNING,(msg)) 00037 # define SYSERR(msg) FXSystemLogger::instance().error(FXSystemLogger::PRI_ERROR,(msg)) 00038 #else 00039 # define SYSLOG(msg) 00040 # define SYSALERT(msg) 00041 # define SYSWRN(msg) 00042 # define SYSERR(msg) 00043 #endif 00044 00045 /** 00046 * Generic interface to operating system logging facility 00047 * This object is a singleton 00048 */ 00049 class FXAPI FXSystemLogger : public FXObject { 00050 FXDECLARE(FXSystemLogger) 00051 00052 private: 00053 static FXSystemLogger* thislog; // self reference indicator 00054 00055 public: 00056 static const FXint PRI_ERROR; 00057 static const FXint PRI_WARNING; 00058 static const FXint PRI_NORMAL; 00059 static const FXint PRI_DEBUG; 00060 00061 public: 00062 enum { 00063 ID_SYSLOG, 00064 ID_LAST 00065 }; 00066 00067 public: 00068 long onCmdLog(FXObject*,FXSelector,void*); 00069 long onCmdSetValue(FXObject*,FXSelector,void*); 00070 long onCmdSetIntValue(FXObject*,FXSelector,void*); 00071 long onCmdSetStringValue(FXObject*,FXSelector,void*); 00072 00073 public: 00074 /// Give me access to the system log 00075 FXSystemLogger(); 00076 00077 /// Use the current instance 00078 static FXSystemLogger& instance(); 00079 00080 /// Log to syslog 00081 void log(const FXint priority, const FXchar* msg, ...); 00082 void log(const FXint priority, const FXString& msg); 00083 void log(const FXString& msg); 00084 void warning(const FXString& msg); 00085 void error(const FXString& msg); 00086 void log(const FXException* e); 00087 void log(const FXExtendedException* e); 00088 00089 /// done 00090 virtual ~FXSystemLogger(); 00091 }; 00092 00093 } // namespace FXEX 00094 #endif // FXSYSTEMLOGGER_H