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

TSystemLogging.hh

解説を見る。
00001 // =====================================================================
00042 // =====================================================================
00043 #ifndef CLDAQ__TSYSTEMLOGGING_HH
00044 #define CLDAQ__TSYSTEMLOGGING_HH
00045 
00046 #include "Tglobals.h"
00047 
00067 class TSystemLogging
00068 {
00069 
00070   public:
00072     enum {
00074       CONS = LOG_CONS, 
00076       NDELAY = LOG_NDELAY,
00078       NOWAIT = LOG_NOWAIT,
00080       ODELAY = LOG_ODELAY,
00082       PERORR = LOG_PERROR,
00084       PID = LOG_PID
00085     };
00086 
00088     enum {
00090       AUTH = LOG_AUTH,
00092       AUTHPRIV = LOG_AUTHPRIV,
00094       CRON = LOG_CRON,
00096       DAEMON = LOG_DAEMON,
00098       FTP = LOG_FTP,
00100       KERN = LOG_KERN,
00102       LOCAL0 = LOG_LOCAL0,
00104       LOCAL1 = LOG_LOCAL1,
00106       LOCAL2 = LOG_LOCAL2,
00108       LOCAL3 = LOG_LOCAL3,
00110       LOCAL4 = LOG_LOCAL4,
00112       LOCAL5 = LOG_LOCAL5,
00114       LOCAL6 = LOG_LOCAL6,
00116       LOCAL7 = LOG_LOCAL7,
00118       LPR = LOG_LPR,
00120       MAIL = LOG_MAIL,
00122       NEWS = LOG_NEWS,
00124       SYSLOG = LOG_SYSLOG,
00126       USER = LOG_USER,
00128       UUCP = LOG_UUCP
00129     };
00130 
00132     enum {
00134       EMERG = LOG_EMERG,
00136       ALERT = LOG_ALERT,
00138       CRIT = LOG_CRIT,
00140       ERROR = LOG_ERR,
00142       WARNING = LOG_WARNING,
00144       NOTICE = LOG_NOTICE,
00146       INFO = LOG_INFO,
00148       DEBUG = LOG_DEBUG
00149     };
00150 
00151 
00152   private:
00153     Tint theLevel;
00154     Tint theFacility;
00155     Tint theOption;
00156     Tstring theID;
00157     Tstring theMessageBuffer;
00158 
00159   public:
00160     TSystemLogging( Tint level=INFO, Tint facility=USER, Tint option=PID|ODELAY );
00161     TSystemLogging( const TSystemLogging& right );
00162     ~TSystemLogging();
00163 
00164   public:
00165     Tvoid Open( Tint option, Tint facility );
00166     Tvoid Open( Tint option );
00167     Tvoid Open();
00168     Tvoid Close();
00169     Tvoid Record( Tint level, const Tstring& format, ...);
00170     Tvoid Record( const Tstring& format, ...);
00171     Tvoid Record( Tint level, const Tstring& format, va_list ap );
00172     Tvoid Record( const Tstring& format, va_list ap );
00173 
00174   public:
00175     Tint GetLevel() const;
00176     Tint GetFacility() const;
00177     Tint GetOption() const;
00178     const Tstring& GetID() const;
00179     const Tstring& GetMessageBuffer() const;
00180     Tvoid SetLevel( Tint level );
00181     Tvoid SetFacility( Tint facility );
00182     Tvoid SetOption( Tint option );
00183     Tvoid SetID( const Tstring& ident );
00184     Tvoid SetID();
00185     Tvoid SetMessageBuffer( const Tstring& buffer );
00186 
00187   public:
00188     Tvoid AddBuffer( const Tstring& message );
00189     Tvoid ClearBuffer();
00190 
00191   public:
00192     const TSystemLogging& operator=( const TSystemLogging& right );
00193     TSystemLogging& operator<<( Tostream& (*pf)(Tostream&) );
00194     TSystemLogging& operator<<( Tostream& os );
00195     TSystemLogging& operator<<( const Tstring& message );
00196     TSystemLogging& operator<<( Tdouble n );
00197     TSystemLogging& operator<<( Tdouble* n );
00198     TSystemLogging& operator<<( Tfloat n );
00199     TSystemLogging& operator<<( Tfloat* n );
00200     TSystemLogging& operator<<( Tint n );
00201     TSystemLogging& operator<<( Tint* n );
00202     TSystemLogging& operator<<( TUint n );
00203     TSystemLogging& operator<<( TUint* n );
00204     TSystemLogging& operator<<( Tshort n );
00205     TSystemLogging& operator<<( Tshort* n );
00206     TSystemLogging& operator<<( TUshort n );
00207     TSystemLogging& operator<<( TUshort* n );
00208     TSystemLogging& operator<<( Tlong n );
00209     TSystemLogging& operator<<( Tlong* n );
00210     TSystemLogging& operator<<( TUlong n );
00211     TSystemLogging& operator<<( TUlong* n );
00212     TSystemLogging& operator<<( Tchar n );
00213     TSystemLogging& operator<<( TUchar n );
00214 
00215 #ifdef __CLDAQ_ROOT_DLL
00216     ClassDef(TSystemLogging,0)
00217 #endif
00218 
00219 };
00220 
00221 inline Tvoid TSystemLogging::AddBuffer( const Tstring& message )
00222 {
00223   theMessageBuffer += message;
00224   return;
00225 }
00226 
00227 inline Tvoid TSystemLogging::ClearBuffer()
00228 {
00229   theMessageBuffer.clear();
00230   return;
00231 }
00232 
00233 inline TSystemLogging& TSystemLogging::operator<<( Tostream& os )
00234 {
00235   return *this;
00236 }
00237 
00238 inline TSystemLogging& TSystemLogging::operator<<( const Tstring& message )
00239 {
00240   AddBuffer( message );
00241   return *this;
00242 }
00243 
00244 inline TSystemLogging& TSystemLogging::operator<<( Tchar n )
00245 {
00246   Tstring s(1,n);
00247   return *this << s;
00248 }
00249 
00250 inline TSystemLogging& TSystemLogging::operator<<( TUchar n )
00251 {
00252   Tstring s(1,(Tchar)n);
00253   return *this << s;
00254 }
00255 
00256 inline TSystemLogging& TSystemLogging::operator<<( Tdouble n )
00257 {
00258   return *this << dtostr( n, 0 );
00259 }
00260 
00261 inline TSystemLogging& TSystemLogging::operator<<( Tdouble* n )
00262 {
00263   return *this << (Tint*)n;
00264 }
00265 
00266 inline TSystemLogging& TSystemLogging::operator<<( Tfloat n )
00267 {
00268   return *this << ftostr( n, 0 );
00269 }
00270 
00271 inline TSystemLogging& TSystemLogging::operator<<( Tfloat* n )
00272 {
00273   return *this << (Tint*)n;
00274 }
00275 
00276 inline TSystemLogging& TSystemLogging::operator<<( Tint n )
00277 {
00278   return *this << itostr( n, 0 );
00279 }
00280 
00281 inline TSystemLogging& TSystemLogging::operator<<( TUint n )
00282 {
00283   return *this << ultostr( n, 0 );
00284 }
00285 
00286 inline TSystemLogging& TSystemLogging::operator<<( TUint* n )
00287 {
00288   return *this << (Tint*)n;
00289 }
00290 
00291 inline TSystemLogging& TSystemLogging::operator<<( Tshort n )
00292 {
00293   return *this << itostr( n, 0 );
00294 }
00295 
00296 inline TSystemLogging& TSystemLogging::operator<<( Tshort* n )
00297 {
00298   return *this << (Tint*)n;
00299 }
00300 
00301 inline TSystemLogging& TSystemLogging::operator<<( TUshort n )
00302 {
00303   return *this << ultostr( n, 0 );
00304 }
00305 
00306 inline TSystemLogging& TSystemLogging::operator<<( TUshort* n )
00307 {
00308   return *this << (Tint*)n;
00309 }
00310 
00311 inline TSystemLogging& TSystemLogging::operator<<( Tlong n )
00312 {
00313   return *this << ltostr( n, 0 );
00314 }
00315 
00316 inline TSystemLogging& TSystemLogging::operator<<( Tlong* n )
00317 {
00318   return *this << (Tint*)n;
00319 }
00320 
00321 inline TSystemLogging& TSystemLogging::operator<<( TUlong n )
00322 {
00323   return *this << ultostr( n, 0 );
00324 }
00325 
00326 inline TSystemLogging& TSystemLogging::operator<<( TUlong* n )
00327 {
00328   return *this << (Tint*)n;
00329 }
00330 
00331 inline Tint TSystemLogging::GetLevel() const
00332 {
00333   return theLevel;
00334 }
00335 
00336 inline Tint TSystemLogging::GetFacility() const
00337 {
00338   return theFacility;
00339 }
00340 
00341 inline Tint TSystemLogging::GetOption() const
00342 {
00343   return theOption;
00344 }
00345 
00346 inline const Tstring& TSystemLogging::GetID() const
00347 {
00348   return theID;
00349 }
00350 
00351 inline const Tstring& TSystemLogging::GetMessageBuffer() const
00352 {
00353   return theMessageBuffer;
00354 }
00355 
00356 inline Tvoid TSystemLogging::SetLevel( Tint level )
00357 {
00358   theLevel = level;
00359   SetID();
00360   return;
00361 }
00362 
00363 inline Tvoid TSystemLogging::SetFacility( Tint facility )
00364 {
00365   theFacility = facility;
00366   return;
00367 }
00368 
00369 inline Tvoid TSystemLogging::SetOption( Tint option )
00370 {
00371   theOption = option;
00372   return;
00373 }
00374 
00375 inline Tvoid TSystemLogging::SetID( const Tstring& ident )
00376 {
00377   theID = ident;
00378   return;
00379 }
00380 
00381 inline Tvoid TSystemLogging::SetMessageBuffer( const Tstring& buffer )
00382 {
00383   theMessageBuffer = buffer;
00384   return;
00385 }
00386 
00387 #ifdef __cplusplus
00388 extern "C" {
00389 #endif
00390 
00391   // EMERG    標準エラー出力し,EXIT_FAILUREし,システム全員にメッセージを送る
00392   // ALERT    標準エラー出力し,EXIT_FAILUREし,ログする
00393   // CRIT     標準エラー出力かつ,EXIT_SUCCESSし,ログされる
00394   // -------------------
00396   // ERROR    標準エラー出力かつログされる
00397   // WARNING  標準出力かつログされる
00398   // NOTICE   標準出力かつログされる
00399   // INFO     標準出力かつログされる
00400   // DEBUG    標準出力するがログされない
00401   namespace Tstd {
00402     static TSystemLogging Temerg(TSystemLogging::EMERG);
00403     static TSystemLogging Talert(TSystemLogging::ALERT);
00404     static TSystemLogging Tcrit(TSystemLogging::CRIT);
00405     static TSystemLogging Terror(TSystemLogging::ERROR);
00406     static TSystemLogging Twarn(TSystemLogging::WARNING);
00407     static TSystemLogging Tnotice(TSystemLogging::NOTICE);
00408     static TSystemLogging Tinfo(TSystemLogging::INFO);
00409     static TSystemLogging Tdebug(TSystemLogging::DEBUG);
00410   }
00411 #ifdef __cplusplus
00412 }
00413 #endif
00414 
00415 #endif

CLDAQ - a Class Library for Data AcQuisition (Version 1.13.0)
Go IWAI <goiwai@users.sourceforge.jp>