Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Examples  

slog.h

Go to the documentation of this file.
00001 // Copyright (C) 1999-2002 Open Source Telecom Corporation.
00002 //
00003 // This program is free software; you can redistribute it and/or modify
00004 // it under the terms of the GNU General Public License as published by
00005 // the Free Software Foundation; either version 2 of the License, or
00006 // (at your option) any later version.
00007 //
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00016 //
00017 // As a special exception to the GNU General Public License, permission is
00018 // granted for additional uses of the text contained in its release
00019 // of Common C++.
00020 //
00021 // The exception is that, if you link the Common C++ library with other
00022 // files to produce an executable, this does not by itself cause the
00023 // resulting executable to be covered by the GNU General Public License.
00024 // Your use of that executable is in no way restricted on account of
00025 // linking the Common C++ library code into it.
00026 //
00027 // This exception does not however invalidate any other reasons why
00028 // the executable file might be covered by the GNU General Public License.
00029 //
00030 // This exception applies only to the code released under the
00031 // name Common C++.  If you copy code from other releases into a copy of
00032 // Common C++, as the General Public License permits, the exception does
00033 // not apply to the code that you add in this way.  To avoid misleading
00034 // anyone as to the status of such modified files, you must delete
00035 // this exception notice from them.
00036 //
00037 // If you write modifications of your own for Common C++, it is your choice
00038 // whether to permit this exception to apply to your modifications.
00039 // If you do not wish that, delete this exception notice.
00040 
00046 #ifndef CCXX_SLOG_H_
00047 #define CCXX_SLOG_H_
00048 
00049 #ifndef CCXX_CONFIG_H_
00050 #include <cc++/config.h>
00051 #endif
00052 
00053 #ifndef CCXX_THREAD_H_
00054 #include <cc++/thread.h>
00055 #endif
00056 
00057 #include <fstream>
00058 #include <iostream>
00059 
00060 #ifdef  CCXX_NAMESPACES
00061 namespace ost {
00062 #endif
00063 
00064 
00106 #if defined(__KCC)
00107 #define ostream ostream_withassign
00108 #endif
00109 class CCXX_CLASS_EXPORT Slog : protected std::streambuf, public std::ostream
00110 {
00111 public:
00112         typedef enum Class
00113         {
00114                 classSecurity,
00115                 classAudit,
00116                 classDaemon,
00117                 classUser,
00118                 classDefault,
00119                 classLocal0,
00120                 classLocal1,
00121                 classLocal2,
00122                 classLocal3,
00123                 classLocal4,
00124                 classLocal5,
00125                 classLocal6,
00126                 classLocal7
00127         } Class;
00128 
00129         typedef enum Level
00130         {
00131                 levelEmergency = 1,
00132                 levelAlert,
00133                 levelCritical,
00134                 levelError,
00135                 levelWarning,
00136                 levelNotice,
00137                 levelInfo,
00138                 levelDebug
00139         } Level;
00140 
00141 private:
00142 #ifndef HAVE_SYSLOG_H
00143         Mutex lock;
00144         std::ofstream syslog;
00145 #endif
00146         int priority;
00147         Level  _level;
00148         bool _enable;
00149         bool _clogEnable;
00150 
00151 protected:
00157         int overflow(int c);
00158 
00159 public:
00167         Slog(void);
00168 
00169         virtual ~Slog(void);
00170 
00171         void close(void);
00172 
00178         void open(const char *ident, Class grp = classUser);
00179 
00186         Slog &operator()(const char *ident, Class grp = classUser,
00187                          Level level = levelError);
00188 
00194         Slog &operator()(Level level, Class grp = classDefault);
00195 
00199         Slog &operator()(void);
00200 
00205         inline void level(Level enable)
00206                 {_level = enable;};
00207 
00213         inline void clogEnable(bool f=true)
00214                 {_clogEnable = f;};
00215 };
00216 
00217 #ifdef  CYGWIN_IMPORTS
00218 extern __declspec(dllimport) Slog slog;
00219 #else
00220 extern CCXX_EXPORT(Slog)        slog;
00221 #endif
00222 
00223 #ifdef  CCXX_NAMESPACES
00224 };
00225 #endif
00226 
00227 #endif
00228 

Generated on Thu Nov 21 12:28:31 2002 for GNU CommonC++ by doxygen1.2.18