Main Page Class Hierarchy Compound List File List Compound Members File Members

# logger.h

Go to the documentation of this file.

    00001 //---------------------------------------------------------------------------
    00002 #ifndef LoggerH
    00003 #define LoggerH
    00004 //---------------------------------------------------------------------------
    00005
    00006 #include <worm_statuscode.h>
    00007 #include <timefuncs.h>       // WORM_TIMESTR_LENGTH
    00008 #include <mutex.h>
    00009
    00010 #include <fstream>
    00011
    00012 typedef short WORM_LOG_FLAGS;
    00013 #define WORM_LOG_TOFILE    0x01
    00014 #define WORM_LOG_TOSTDOUT  0x02
    00015 #define WORM_LOG_TOSTDERR  0x04
    00016 #define WORM_LOG_TIMESTAMP 0x08
    00017 #define WORM_LOG_PIDSTAMP  0x10
    00018 #define WORM_LOG_NAMESTAMP 0x20
    00019
    00020
    00021
    00022
    00023 //---------------------------------------------------------------------------
    00024 class TLogger
    00025 {
    00026 protected:
    00027    static TMutex * AccessLock;
    00028    static std::fstream OutStream;
    00029    static char PreviousDate[WORM_TIMESTR_LENGTH+1];
    00030    static bool TruncOnOpen;
    00031    static WORM_STATUS_CODE OpenFile();
    00032    static int MaxTooLongLength; // track the length of the longest message that was too long
    00033 public:
    00034    static void TruncateOnOpen( bool p_newstate = true ) { TruncOnOpen = p_newstate; }
    00035    /*  Logit()
    00036    **
    00037    ** RETURNS:  length (count) of variable parameter list
    00038    **           -1 = error
    00039    */
    00040    static int Logit( WORM_LOG_FLAGS p_flags, const char* p_format, ... );
    00041    static void Close();
    00042 };
    00043
    00044 #endif