forked from cilel/VS_positioning_Z
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyLog.h
73 lines (53 loc) · 1.57 KB
/
myLog.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef myLog_H
#define myLog_H 1
#include <fstream>
#include <iostream>
#include <string>
#include <time.h>
using namespace std;
/*
the log file has to be accessed from any code
which includes this header (similiar to cout, cerr, clog, etc..)
*/
class myLog;
extern myLog winLog;
const string SD_DEFAULT_LOGFILE = "LOG FILE.log";
const int LOG_WRITE = ios::out;
const int LOG_APPEND = ios::app;
const int EXIT_MSG_SIZE = 512;
const int MAX_EXIT_CODES = 3;
class myLog : public ofstream
{
public:
enum logLevels
{
LEVEL_0, // buffer all log messages
LEVEL_1, // buffer Level one, two and three log messages
LEVEL_2, // buffer Level two and three log messages
LEVEL_3, // buffer Level three log messages
QUIET_MODE // do not print out any messages
};
myLog();
myLog(const string&);
myLog(const string&,enum logLevels);
virtual ~myLog();
private:
void initVars();
void init(const string&);
void init(const string&,int);
void init();
char* getExecTime();
void getExecTime(int*,int*);
void openLog(const string&,int);
void printHeader(int);
private:
string logName;
enum logLevels logLevel;
time_t startTime;
};
const enum myLog::logLevels L0 = myLog::LEVEL_0;
const enum myLog::logLevels L1 = myLog::LEVEL_1;
const enum myLog::logLevels L2 = myLog::LEVEL_2;
const enum myLog::logLevels L3 = myLog::LEVEL_3;
const enum myLog::logLevels LQUIET = myLog::QUIET_MODE;
#endif