Advertisement
natli

Untitled

Dec 9th, 2011
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.97 KB | None | 0 0
  1. //-*-C++-*-///////////////////////////////////////////////////////////////////
  2. //   Copyright 2004 yuChen Technology.  All Rights Reserved.
  3. //
  4. //   Class: myLog
  5. //
  6. //   Description: used as a system log file for the simDelta project
  7. //
  8. //   Name of Designer:  Liyang Yu
  9. //   Name of Coder:     Liyang Yu
  10. //   Date:              01/27/04
  11. //
  12. //////////////////////////////////////////////////////////////////////////////
  13.  
  14. #ifndef myLog_H
  15. #define myLog_H 1
  16.  
  17. #include <fstream>
  18. #include <iostream>
  19. #include <string>
  20. #include <time.h>
  21. using namespace std;
  22.  
  23. /*
  24.    the log file has to be accessed from any code
  25.    which includes this header (similiar to cout, cerr, clog, etc..)
  26. */
  27.  
  28. class myLog;
  29. extern myLog winLog;
  30.  
  31. // const string SD_DEFAULT_LOGFILE = "simDelta.log";
  32.  
  33. const int LOG_WRITE  = ios::out;
  34. const int LOG_APPEND = ios::app;
  35.  
  36. const int EXIT_MSG_SIZE = 512;
  37. const int MAX_EXIT_CODES = 3;
  38.  
  39. class myLog : public ofstream
  40. {
  41.  
  42. public:
  43.  
  44.    enum logLevels
  45.    {
  46.       LEVEL_0,       // buffer all log messages
  47.       LEVEL_1,       // buffer Level one, two and three log messages
  48.       LEVEL_2,       // buffer Level two and three log messages
  49.       LEVEL_3,       // buffer Level three log messages
  50.       QUIET_MODE     // do not print out any messages
  51.    };
  52.  
  53.    myLog();
  54.    myLog(const string&);
  55.    myLog(const string&,enum logLevels);
  56.    virtual ~myLog();
  57.  
  58. private:
  59.  
  60.    void initVars();
  61.    void init(const string&);
  62.    void init(const string&,int);
  63.    void init();
  64.  
  65.    char* getExecTime();
  66.    void  getExecTime(int*,int*);
  67.    void  openLog(const string&,int);
  68.    void  printHeader(int);
  69.  
  70. private:
  71.  
  72.    string logName;
  73.    enum logLevels logLevel;
  74.    time_t startTime;
  75.  
  76. };
  77.  
  78. const enum myLog::logLevels L0 = myLog::LEVEL_0;
  79. const enum myLog::logLevels L1 = myLog::LEVEL_1;
  80. const enum myLog::logLevels L2 = myLog::LEVEL_2;
  81. const enum myLog::logLevels L3 = myLog::LEVEL_3;
  82. const enum myLog::logLevels LQUIET = myLog::QUIET_MODE;
  83.  
  84. #endif
  85.  
  86.  
  87.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement