-
Notifications
You must be signed in to change notification settings - Fork 0
/
Logger.h
68 lines (52 loc) · 1.23 KB
/
Logger.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
//
// Created by André Schnabel on 10.10.17.
//
#pragma once
#include <string>
#include <fstream>
#include "Stopwatch.h"
namespace Utils {
class Logger {
public:
enum class LogLevel {
INFO = 0,
WARNING,
ERROR
};
enum class LogMode {
QUIET = 0,
MEDIUM,
VERBOSE
};
private:
std::string logName;
std::ofstream f;
LogMode mode;
static Logger *instance;
public:
Logger(const std::string &_logName, LogMode _mode);
void log(LogLevel level, const std::string &message);
static Logger *getInstance();
};
class Tracer {
public:
enum class TraceMode {
ONLY_COUNT = 0,
ONLY_INTERVAL,
BOTH
};
explicit Tracer(const std::string &filePrefix = "SolverTrace", TraceMode _traceMode = TraceMode::ONLY_INTERVAL);
~Tracer();
void trace(double slvtime, float bks_objval, int nschedules, int nindividuals, bool trunc_secs = false);
void countTrace(float bks_objval, int nschedules, int nindividuals);
void intervalTrace(float bks_objval, int nschedules, int nindividuals);
void setTraceMode(TraceMode _traceMode);
private:
std::ofstream f;
std::chrono::time_point<std::chrono::system_clock> lupdate;
double last_slvtime;
Stopwatch sw;
TraceMode traceMode;
int lastNumSchedules;
};
}