-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLogger.h
More file actions
67 lines (63 loc) · 2.32 KB
/
Logger.h
File metadata and controls
67 lines (63 loc) · 2.32 KB
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
/** @file Logger.h
*A simple logger class to tag and record logging messages.
*
*Copyright 2015, 2021 by Francisco Cancillo & Luis Cancillo
*<p>
*This file is part of the RXtoRINEX tools and toRINEX APP.
*<p>
*RXtoRINEX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
*as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*RXtoRINEX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
*warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*See the GNU General Public License for more details.
*<p>
*A copy of the GNU General Public License can be found at <http://www.gnu.org/licenses/>.
*
*<p>Ver. |Date |Reason for change
*<p>---------------------------------
*<p>V1.0 |2/2015 |First release
*/
#ifndef LOGGER_H
#define LOGGER_H
#include <string>
#include <time.h>
#include <stdio.h>
#include <string.h>
using namespace std;
/** Logger class allows recording of tagged messages.
*<p>A program using Logger would perform the following steps:
* -# Define a Logger object stating the fileName of the logging file, or using the default stderr.
* -# State the desired log level. Can be SEVERE, WARNING, INFO, CONFIG, FINE, FINER or FINEST.
If the log level is not explicitly stated, the default level is INFO.
* -# Log any message that would be necessary using the method corresponding to the desired log level of the message.
* Only those messages having level from SEVERE to the current level stated are recorded in the log file.
*/
class Logger {
public:
///The log levels defined in this class
enum logLevel {SEVERE=0, WARNING, INFO, CONFIG, FINE, FINER, FINEST};
//Constructors and destructor
Logger(string, string, string);
Logger(string);
Logger(void);
~Logger(void);
void setPrgName(string);
void setLevel(logLevel);
void setLevel(string);
bool isLevel(logLevel);
bool isLevel(string);
void severe(string);
void warning(string);
void info(string);
void config(string);
void fine(string);
void finer(string);
void finest(string);
private:
string program; //program name to tag logs
logLevel levelSet; //maximum level to log
FILE * fileLog;
void logMsg(logLevel msgLevel, string msg);
logLevel identifyLevel(string level);
};
#endif