Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

muo_logging.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2001 Karsten Reincke <reincke@gnukose.org>
00003  *  
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software 
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  *  
00018  * file <muo_logging.h> version <#1.3.1#> of project <MrProjext>
00019  */   
00020 
00027 #ifndef  MUO_LOGGING_H
00028 #define  MUO_LOGGING_H
00029 
00030 #ifdef HAVE_CONFIG_H
00031 #include <config.h>
00032 #endif
00033 #include <string>
00034 #include <stdio.h>
00035 #include <stdlib.h>
00036 /* &&& exported preprocessor-defines &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& */
00037 #define SHOW_NO_MESSAGES 0 
00038 #define SHOW_NM 0  
00039 #define SHOW_SIGNALS 1  
00040 #define SHOW_SM 1 
00041 #define SHOW_SIGNALS_AND_DESCRIPTIONS 2 
00042 #define SHOW_SMADM 2  
00043 #define SHOW_SIGNALS_DESCRIPTIONS_AND_HINTS 3 
00044 #define SHOW_SMADMAHM 3 
00045 
00046 #define USE_SHARED_LOGFILE true 
00047 #define USE_OWN_LOGFILE false  
00048 #define WITH_SCREEN_MESSAGES true 
00049 #define WITHOUT_SCREEN_MESSAGES false  
00050 
00051 #define USE_TWOLINES true 
00052 #define USE_ONELINE false 
00053 #define SIGNAL_MESSAGE 1  
00054 #define SMESS 1           
00055 #define SM 1              
00056 #define DESCRIPTION_MESSAGE 2 
00057 #define DMESS 2               
00058 #define DM 2                  
00059 #define HINT_MESSAGE 3  
00060 #define HMESS 3         
00061 #define HM 3            
00062 /* &&& class-declarations &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& */
00063 
00064 using namespace std;
00065 
00066 namespace krmuo
00067 {
00068 
00075 class LoggingUnit
00076 {
00077   /* &&& attributes &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& */
00078   public:
00079   private:
00084     unsigned int mMaxVisibleMessageLevel;
00088     FILE *mScreen;
00092     const string mLogFileName;
00096     FILE *mFile;
00104     bool mUsesSharedLoggingFile;
00105   protected:
00106   
00107   /* &&& methods &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& */
00108   
00109   public:
00110   
00111     /* :-: public constructors / init / operators :-:-:-:-:-:-:-: */
00112     
00116     LoggingUnit
00117     ( const unsigned int pMaxVisibleMessageLevel,
00118       FILE *pScreen);
00119 
00123     LoggingUnit
00124     ( const unsigned int pMaxVisibleMessageLevel,
00125       const string& pLogFileName,
00126       const bool pUsesSharedLoggingFile);
00127     
00131     LoggingUnit
00132     ( const unsigned int pMaxVisibleMessageLevel,
00133       FILE *pScreen, 
00134       const string& pLogFileName,
00135       const bool pUsesSharedLoggingFile);
00136     
00137     ~LoggingUnit();                      
00138           
00139     /* :-: public getter :-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: */
00140     /* :-: public setter :-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: */ 
00146     inline void turnOffScreenWriting() { mScreen=NULL; };
00147     
00148     /* :-: public others :-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: */
00152     void makeEntry( const string& pLogString,
00153                     const unsigned int pLogEntryLevel) const;
00157     void makeEntry( const string& pLogString1,
00158                     const string& pLogString2, 
00159                     const unsigned int pLogEntryLevel) const;
00160 
00164     void makeEntry( const string& pLogString1,
00165                     const string& pLogString2, 
00166                     const string& pLogString3, 
00167                     const unsigned int pLogEntryLevel) const;
00168 
00172     void makeEntry( const string& pLogString1,
00173                     const string& pLogString2,
00174                     const unsigned int pLogEntryLevel,
00175                     bool pTwoLine) const;
00179     void makeEntry( const string& pLogString1,
00180                     const string& pLogString2,
00181                     const string& pLogString3,
00182                     const unsigned int pLogEntryLevel,
00183                     bool pTwoLine) const;
00187     void makeEntry( const string& pLogString,
00188                     const unsigned int pLogUInt, 
00189                     const unsigned int pLogEntryLevel) const;
00193     void makeEntry( const string& pLogString,
00194                     const int pLogInt, 
00195                     const unsigned int pLogEntryLevel) const;
00196     
00197   private:
00198     /* :-: private constructors / init / operators :-:-:-:-:-:-: */
00199      LoggingUnit(const LoggingUnit& co);     
00200     /* :-: private getter -:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: */
00201     /* :-: private setter -:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: */
00202     /* :-: private others -:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: */
00206     void fillTimeLabel(string& pTimeLabel) const;
00207   protected:
00208     /* :-: protected getter :-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: */
00209     /* :-: protected setter :-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: */
00210     /* :-: protected others :-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: */
00211   
00212 };
00221 class LoggingSuitcase
00222 {
00223   /* &&& attributes &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& */
00224   public:
00225   private:
00226     LoggingUnit mActionLoggingUnit;
00227     LoggingUnit mWarnLoggingUnit;
00228     LoggingUnit mErrorLoggingUnit;
00229   protected:
00230   
00231   /* &&& methods &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& */
00232   
00233   public:
00234   
00235     /* :-: public constructors / init / operators :-:-:-:-:-:-:-: */
00236 
00240     LoggingSuitcase
00241     ( const unsigned int pActionMessageLevel,
00242       const unsigned int pErrorMessageLevel
00243     );                       
00244     
00248     LoggingSuitcase
00249     ( const unsigned int pShowActionMessages,
00250       const unsigned int pShowErrorMessages,
00251       const string& pLogDirPath,
00252       const string& pLogFileNameKernel,
00253       bool pUsesSharedLoggingFile
00254     );
00255         
00259     LoggingSuitcase
00260     ( const unsigned int pShowActionMessages,
00261       const unsigned int pShowErrorMessages,
00262       bool pWithScreenMessages,
00263       const string& pLogDirPath,
00264       const string& pLogFileNameKernel,
00265       bool pUsesSharedLoggingFile
00266     );
00267 
00268     ~LoggingSuitcase();                      
00269         
00270   
00271     /* :-: public getter :-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: */
00272     /* :-: public setter :-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: */
00273     
00279     inline void turnOffScreenWriting() 
00280     { 
00281       mErrorLoggingUnit.turnOffScreenWriting();
00282       mWarnLoggingUnit.turnOffScreenWriting();
00283       mActionLoggingUnit.turnOffScreenWriting();
00284     };
00285     
00286     
00287     /* :-: public others :-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: */
00288     
00292     inline
00293     void makeActionLogEntry
00294     ( const string& pLogString,
00295       const unsigned int pLogEntryLevel
00296     )const
00297     {
00298       mActionLoggingUnit.makeEntry(pLogString,pLogEntryLevel);
00299     }
00300 
00304     inline
00305     void makeActionLogEntry
00306     ( const string& pLogString1,
00307       const string& pLogString2,
00308       const unsigned int pLogEntryLevel
00309     )const
00310     {
00311       mActionLoggingUnit.makeEntry(pLogString1,pLogString2,pLogEntryLevel);
00312     }
00313     
00318     inline
00319     void makeActionLogEntry
00320     ( const string& pLogString1,
00321       const string& pLogString2,
00322       const unsigned int pLogEntryLevel,
00323       bool pTwoLine
00324     )const
00325     {
00326       mActionLoggingUnit.makeEntry(pLogString1,pLogString2,pLogEntryLevel,pTwoLine);
00327     }
00328     
00332     inline
00333     void makeActionLogEntry
00334     ( const string& pLogString,
00335       const unsigned int pLogUInt,
00336       const unsigned int pLogEntryLevel
00337     )const
00338     {
00339       mActionLoggingUnit.makeEntry(pLogString,pLogUInt,pLogEntryLevel);
00340     }
00341 
00345     inline
00346     void makeActionLogEntry
00347     ( const string& pLogString,
00348       const int pLogInt,
00349       const unsigned int pLogEntryLevel
00350     )const
00351     {
00352       mActionLoggingUnit.makeEntry(pLogString,pLogInt,pLogEntryLevel);
00353     }
00354 
00358     inline
00359     void makeWarnLogEntry
00360     ( const string& pLogString,
00361       const unsigned int pLogEntryLevel
00362     )const
00363     {
00364       mWarnLoggingUnit.makeEntry(pLogString,pLogEntryLevel);
00365     }
00366 
00370     inline
00371     void makeWarnLogEntry
00372     ( const string& pLogString1,
00373       const string& pLogString2,
00374       const unsigned int pLogEntryLevel
00375     )const
00376     {
00377       mWarnLoggingUnit.makeEntry(pLogString1,pLogString2,pLogEntryLevel);
00378     }
00379     
00384     inline
00385     void makeWarnLogEntry
00386     ( const string& pLogString1,
00387       const string& pLogString2,
00388       const unsigned int pLogEntryLevel,
00389       bool pTwoLine
00390     )const
00391     {
00392       mWarnLoggingUnit.makeEntry(pLogString1,pLogString2,pLogEntryLevel,pTwoLine);
00393     }
00394     
00398     inline
00399     void makeWarnLogEntry
00400     ( const string& pLogString,
00401       const unsigned int pLogUInt,
00402       const unsigned int pLogEntryLevel
00403     )const
00404     {
00405       mWarnLoggingUnit.makeEntry(pLogString,pLogUInt,pLogEntryLevel);
00406     }
00407 
00411     inline
00412     void makeWarnLogEntry
00413     ( const string& pLogString,
00414       const int pLogInt,
00415       const unsigned int pLogEntryLevel
00416     )const
00417     {
00418       mWarnLoggingUnit.makeEntry(pLogString,pLogInt,pLogEntryLevel);
00419     }
00420     
00424     inline
00425     void makeErrorLogEntry
00426     ( const string& pLogString,
00427       const unsigned int pLogEntryLevel
00428     )const
00429     {
00430       mErrorLoggingUnit.makeEntry(pLogString,pLogEntryLevel);
00431     }
00432 
00436     inline
00437     void makeErrorLogEntry
00438     ( const string& pLogString1,
00439       const string& pLogString2,
00440       const unsigned int pLogEntryLevel
00441     )const
00442     {
00443       mErrorLoggingUnit.makeEntry(pLogString1,pLogString2,pLogEntryLevel);
00444     }
00445     
00450     inline
00451     void makeErrorLogEntry
00452     ( const string& pLogString1,
00453       const string& pLogString2,
00454       const unsigned int pLogEntryLevel,
00455       bool pTwoLine
00456     )const
00457     {
00458       mErrorLoggingUnit.makeEntry(pLogString1,pLogString2,pLogEntryLevel,pTwoLine);
00459     }
00460     
00464     inline
00465     void makeErrorLogEntry
00466     ( const string& pLogString,
00467       const unsigned int pLogUInt,
00468       const unsigned int pLogEntryLevel
00469     )const
00470     {
00471       mErrorLoggingUnit.makeEntry(pLogString,pLogUInt,pLogEntryLevel);
00472     }
00473 
00477     inline
00478     void makeErrorLogEntry
00479     ( const string& pLogString,
00480       const int pLogInt,
00481       const unsigned int pLogEntryLevel
00482     )const
00483     {
00484       mErrorLoggingUnit.makeEntry(pLogString,pLogInt,pLogEntryLevel);
00485     }
00486     
00487   private:
00488     /* :-: private constructors / init / operators :-:-:-:-:-:-: */
00489      LoggingSuitcase(const LoggingSuitcase& co);     
00490     /* :-: private getter -:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: */
00491     /* :-: private setter -:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: */
00492     /* :-: private others -:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: */
00493       
00494   protected:
00495     /* :-: protected getter :-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: */
00496     /* :-: protected setter :-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: */
00497     /* :-: protected others :-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: */
00498   
00499 };
00500 
00501 }
00502 #endif

Generated on Sat Mar 4 11:54:46 2006 for MRPROJEXT by  doxygen 1.4.1