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

TSystemLogging.hh

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

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