TSystemLogging.hh Source File

メインページ モジュール クラス階層 アルファベット順一覧 構成 ファイル一覧 構成メンバ ファイルメンバ 関連ページ 例

# TSystemLogging.hh

解説を見る。

    00001 // =====================================================================
    00030 // =====================================================================
    00031 #ifndef __TSYSTEMLOGGING_HH
    00032 #define __TSYSTEMLOGGING_HH
    00033
    00034 #include "Tglobals.h"
    00035
    00055 class TSystemLogging
    00056 {
    00057
    00058   public:
    00060     enum {
    00062       CONS = LOG_CONS,
    00064       NDELAY = LOG_NDELAY,
    00066       NOWAIT = LOG_NOWAIT,
    00068       ODELAY = LOG_ODELAY,
    00070       PERORR = LOG_PERROR,
    00072       PID = LOG_PID
    00073     };
    00074
    00076     enum {
    00078       AUTH = LOG_AUTH,
    00080       AUTHPRIV = LOG_AUTHPRIV,
    00082       CRON = LOG_CRON,
    00084       DAEMON = LOG_DAEMON,
    00086       FTP = LOG_FTP,
    00088       KERN = LOG_KERN,
    00090       LOCAL0 = LOG_LOCAL0,
    00092       LOCAL1 = LOG_LOCAL1,
    00094       LOCAL2 = LOG_LOCAL2,
    00096       LOCAL3 = LOG_LOCAL3,
    00098       LOCAL4 = LOG_LOCAL4,
    00100       LOCAL5 = LOG_LOCAL5,
    00102       LOCAL6 = LOG_LOCAL6,
    00104       LOCAL7 = LOG_LOCAL7,
    00106       LPR = LOG_LPR,
    00108       MAIL = LOG_MAIL,
    00110       NEWS = LOG_NEWS,
    00112       SYSLOG = LOG_SYSLOG,
    00114       USER = LOG_USER,
    00116       UUCP = LOG_UUCP
    00117     };
    00118
    00120     enum {
    00122       EMERG = LOG_EMERG,
    00124       ALERT = LOG_ALERT,
    00126       CRIT = LOG_CRIT,
    00128       ERROR = LOG_ERR,
    00130       WARNING = LOG_WARNING,
    00132       NOTICE = LOG_NOTICE,
    00134       INFO = LOG_INFO,
    00136       DEBUG = LOG_DEBUG
    00137     };
    00138
    00139
    00140   private:
    00141     Tint theLevel;
    00142     Tint theFacility;
    00143     Tint theOption;
    00144     Tstring theID;
    00145     Tstring theMessageBuffer;
    00146
    00147   public:
    00148     TSystemLogging( Tint level=INFO, Tint facility=USER, Tint option=PID|ODELAY );
    00149     TSystemLogging( const TSystemLogging& right );
    00150     ~TSystemLogging();
    00151
    00152   public:
    00153     Tvoid Open( Tint option, Tint facility );
    00154     Tvoid Open( Tint option );
    00155     Tvoid Open();
    00156     Tvoid Close();
    00157     Tvoid Record( Tint level, const Tstring& format, ...);
    00158     Tvoid Record( const Tstring& format, ...);
    00159     Tvoid Record( Tint level, const Tstring& format, va_list ap );
    00160     Tvoid Record( const Tstring& format, va_list ap );
    00161
    00162   public:
    00163     Tint GetLevel() const;
    00164     Tint GetFacility() const;
    00165     Tint GetOption() const;
    00166     const Tstring& GetID() const;
    00167     const Tstring& GetMessageBuffer() const;
    00168     Tvoid SetLevel( Tint level );
    00169     Tvoid SetFacility( Tint facility );
    00170     Tvoid SetOption( Tint option );
    00171     Tvoid SetID( const Tstring& ident );
    00172     Tvoid SetID();
    00173     Tvoid SetMessageBuffer( const Tstring& buffer );
    00174
    00175   public:
    00176     Tvoid AddBuffer( const Tstring& message );
    00177     Tvoid ClearBuffer();
    00178
    00179   public:
    00180     const TSystemLogging& operator=( const TSystemLogging& right );
    00181     TSystemLogging& operator<<( Tostream& (*pf)(Tostream&) );
    00182     TSystemLogging& operator<<( Tostream& os );
    00183     TSystemLogging& operator<<( const Tstring& message );
    00184     TSystemLogging& operator<<( Tdouble n );
    00185     TSystemLogging& operator<<( Tdouble* n );
    00186     TSystemLogging& operator<<( Tfloat n );
    00187     TSystemLogging& operator<<( Tfloat* n );
    00188     TSystemLogging& operator<<( Tint n );
    00189     TSystemLogging& operator<<( Tint* n );
    00190     TSystemLogging& operator<<( TUint n );
    00191     TSystemLogging& operator<<( TUint* n );
    00192     TSystemLogging& operator<<( Tshort n );
    00193     TSystemLogging& operator<<( Tshort* n );
    00194     TSystemLogging& operator<<( TUshort n );
    00195     TSystemLogging& operator<<( TUshort* n );
    00196     TSystemLogging& operator<<( Tlong n );
    00197     TSystemLogging& operator<<( Tlong* n );
    00198     TSystemLogging& operator<<( TUlong n );
    00199     TSystemLogging& operator<<( TUlong* n );
    00200     TSystemLogging& operator<<( Tchar n );
    00201     TSystemLogging& operator<<( TUchar n );
    00202
    00203 };
    00204
    00205 inline Tvoid TSystemLogging::AddBuffer( const Tstring& message )
    00206 {
    00207   theMessageBuffer += message;
    00208   return;
    00209 }
    00210
    00211 inline Tvoid TSystemLogging::ClearBuffer()
    00212 {
    00213   theMessageBuffer.clear();
    00214   return;
    00215 }
    00216
    00217 inline TSystemLogging& TSystemLogging::operator<<( Tostream& os )
    00218 {
    00219   return *this;
    00220 }
    00221
    00222 inline TSystemLogging& TSystemLogging::operator<<( const Tstring& message )
    00223 {
    00224   AddBuffer( message );
    00225   return *this;
    00226 }
    00227
    00228 inline TSystemLogging& TSystemLogging::operator<<( Tchar n )
    00229 {
    00230   Tstring s(1,n);
    00231   return *this << s;
    00232 }
    00233
    00234 inline TSystemLogging& TSystemLogging::operator<<( TUchar n )
    00235 {
    00236   Tstring s(1,(Tchar)n);
    00237   return *this << s;
    00238 }
    00239
    00240 inline TSystemLogging& TSystemLogging::operator<<( Tdouble n )
    00241 {
    00242   return *this << dtostr( n, 0 );
    00243 }
    00244
    00245 inline TSystemLogging& TSystemLogging::operator<<( Tdouble* n )
    00246 {
    00247   return *this << (Tint*)n;
    00248 }
    00249
    00250 inline TSystemLogging& TSystemLogging::operator<<( Tfloat n )
    00251 {
    00252   return *this << ftostr( n, 0 );
    00253 }
    00254
    00255 inline TSystemLogging& TSystemLogging::operator<<( Tfloat* n )
    00256 {
    00257   return *this << (Tint*)n;
    00258 }
    00259
    00260 inline TSystemLogging& TSystemLogging::operator<<( Tint n )
    00261 {
    00262   return *this << itostr( n, 0 );
    00263 }
    00264
    00265 inline TSystemLogging& TSystemLogging::operator<<( TUint n )
    00266 {
    00267   return *this << ultostr( n, 0 );
    00268 }
    00269
    00270 inline TSystemLogging& TSystemLogging::operator<<( TUint* n )
    00271 {
    00272   return *this << (Tint*)n;
    00273 }
    00274
    00275 inline TSystemLogging& TSystemLogging::operator<<( Tshort n )
    00276 {
    00277   return *this << itostr( n, 0 );
    00278 }
    00279
    00280 inline TSystemLogging& TSystemLogging::operator<<( Tshort* n )
    00281 {
    00282   return *this << (Tint*)n;
    00283 }
    00284
    00285 inline TSystemLogging& TSystemLogging::operator<<( TUshort n )
    00286 {
    00287   return *this << ultostr( n, 0 );
    00288 }
    00289
    00290 inline TSystemLogging& TSystemLogging::operator<<( TUshort* n )
    00291 {
    00292   return *this << (Tint*)n;
    00293 }
    00294
    00295 inline TSystemLogging& TSystemLogging::operator<<( Tlong n )
    00296 {
    00297   return *this << ltostr( n, 0 );
    00298 }
    00299
    00300 inline TSystemLogging& TSystemLogging::operator<<( Tlong* n )
    00301 {
    00302   return *this << (Tint*)n;
    00303 }
    00304
    00305 inline TSystemLogging& TSystemLogging::operator<<( TUlong n )
    00306 {
    00307   return *this << ultostr( n, 0 );
    00308 }
    00309
    00310 inline TSystemLogging& TSystemLogging::operator<<( TUlong* n )
    00311 {
    00312   return *this << (Tint*)n;
    00313 }
    00314
    00315 inline Tint TSystemLogging::GetLevel() const
    00316 {
    00317   return theLevel;
    00318 }
    00319
    00320 inline Tint TSystemLogging::GetFacility() const
    00321 {
    00322   return theFacility;
    00323 }
    00324
    00325 inline Tint TSystemLogging::GetOption() const
    00326 {
    00327   return theOption;
    00328 }
    00329
    00330 inline const Tstring& TSystemLogging::GetID() const
    00331 {
    00332   return theID;
    00333 }
    00334
    00335 inline const Tstring& TSystemLogging::GetMessageBuffer() const
    00336 {
    00337   return theMessageBuffer;
    00338 }
    00339
    00340 inline Tvoid TSystemLogging::SetLevel( Tint level )
    00341 {
    00342   theLevel = level;
    00343   SetID();
    00344   return;
    00345 }
    00346
    00347 inline Tvoid TSystemLogging::SetFacility( Tint facility )
    00348 {
    00349   theFacility = facility;
    00350   return;
    00351 }
    00352
    00353 inline Tvoid TSystemLogging::SetOption( Tint option )
    00354 {
    00355   theOption = option;
    00356   return;
    00357 }
    00358
    00359 inline Tvoid TSystemLogging::SetID( const Tstring& ident )
    00360 {
    00361   theID = ident;
    00362   return;
    00363 }
    00364
    00365 inline Tvoid TSystemLogging::SetMessageBuffer( const Tstring& buffer )
    00366 {
    00367   theMessageBuffer = buffer;
    00368   return;
    00369 }
    00370
    00371 #endif