45#define LOG_MED_UTILS 8
48#define LOG_DATA_STRUCTURES 11
56#define LOG_REPCLEANER 15
58#define LOG_FTRGNRTR 16
62#define LOG_FEATCLEANER 18
66#define MED_SAMPLES_CV 20
68#define LOG_FEAT_SELECTOR 21
70#define LOG_SMPL_FILTER 22
74#define LOG_MED_MODEL 24
78#define MAX_LOG_SECTION 26
86#define MIN_LOG_LEVEL 0
88#define DEBUG_LOG_LEVEL 3
90#define LOG_DEF_LEVEL 5
92#define MAX_LOG_LEVEL 10
93#define VERBOSE_LOG_LEVEL 10
96extern vector<string> log_section_to_name;
97extern vector<string> log_level_to_name;
102 vector<vector<FILE *>> fds;
103 vector<vector<string>> file_names;
105 string out_file_name;
111 void init_all_levels(
int level);
112 int init_all_files(
const string &fname);
113 void init_level(
int section,
int level);
114 void init_file(
int section, FILE *of);
115 int init_file(
int section,
const string &fname);
116 int add_file(
int section,
const string &fname);
119 void init_out(FILE *of);
120 void init_out(
const string &fname);
122 int log(
int section,
int print_level,
const char *fmt, ...);
123 void out(
char *fmt, ...);
130 void init_format(
int section,
const string &new_format);
141#define MEDLOG(Section,Level,fmt,...) global_logger.log(Section,Level,fmt, ##__VA_ARGS__)
143#define MDBG(Level,fmt,...) global_logger.log(LOCAL_SECTION,Level,fmt, ##__VA_ARGS__)
145#define MLOG(fmt,...) global_logger.log(LOCAL_SECTION, LOCAL_LEVEL, fmt, ##__VA_ARGS__)
147#define MLOG_V(fmt,...) global_logger.log(LOCAL_SECTION, VERBOSE_LOG_LEVEL, fmt, ##__VA_ARGS__)
149#define MLOG_D(fmt,...) global_logger.log(LOCAL_SECTION, DEBUG_LOG_LEVEL, fmt, ##__VA_ARGS__)
151#define MERR(fmt,...) global_logger.log(LOCAL_SECTION, MAX_LOG_LEVEL, fmt, ##__VA_ARGS__)
153#define MWARN(fmt,...) global_logger.log(LOCAL_SECTION, MAX_LOG_LEVEL-1, fmt, ##__VA_ARGS__)
155#define MOUT(fmt,...) global_logger.out(fmt, ##__VA_ARGS__)
157#define MTHROW_AND_ERR_STR(fmt,...) {char buff[300];snprintf(buff, sizeof(buff), fmt, ##__VA_ARGS__);global_logger.log(LOCAL_SECTION, MAX_LOG_LEVEL, buff); throw runtime_error(string(buff));}
159#define MTHROW_AND_ERR(fmt,...) {char buff[300];snprintf(buff, sizeof(buff), fmt, ##__VA_ARGS__);global_logger.log(LOCAL_SECTION,MAX_LOG_LEVEL,"RunTime ERROR: ");global_logger.log(LOCAL_SECTION, MAX_LOG_LEVEL, buff); throw std::runtime_error("Error");}
163#define HMTHROW_AND_ERR(fmt,...) {char buff[300];snprintf(buff, sizeof(buff), fmt, ##__VA_ARGS__);global_logger.log(0, MAX_LOG_LEVEL, buff); throw runtime_error(string(buff));}
172 chrono::high_resolution_clock::time_point t[2];
173 unsigned long long diff;
175 MedTimer(
const string &tname) { name = tname; }
178 void start() { t[0] = chrono::high_resolution_clock::now(); }
179 void take_curr_time() { t[1] = chrono::high_resolution_clock::now(); diff = (
unsigned long long)(chrono::duration_cast<chrono::microseconds>(t[1] - t[0]).count()); }
180 unsigned long long get_clock_micro() {
181 auto t_now = chrono::high_resolution_clock::now();
182 auto micro = chrono::duration_cast<chrono::microseconds>(t_now.time_since_epoch());
183 return (
unsigned long long)(micro.count());
186 double diff_microsec() {
return (
double)diff; }
187 double diff_milisec() {
return (
double)diff / 1000.0; }
188 double diff_sec() {
return (
double)diff / 1000000.0; }
197 chrono::high_resolution_clock::time_point tm_start;
198 chrono::high_resolution_clock::time_point tm_prog;
204 bool alway_print_total;
214 MedProgress(
const string &title,
int mprocess_cnt,
int print_inter = 30,
int max_th = 50);
226void get_current_time(
string &time_str);
void init_format(int section, const string &new_format)
sets log format.
Definition Logger.cpp:270
void init_all_formats(int section, const string &new_format)
sets log format for all sections - refer to init_format for more details
Definition Logger.cpp:275
vector< string > format
log format for each section - the message is s, reset is variables with $: time,section,...
Definition Logger.h:106
class to print progress of long process - multithreaded or not by time interval
Definition Logger.h:195
void skip_update()
update action when skiping action - update job counter
Definition Logger.cpp:383
void update_no_check()
update action when without checking if needs to print, faster
Definition Logger.cpp:389
void update()
update when completed process 1 item
Definition Logger.cpp:337
MedTimer - a very simple class to allow very easy time measures.
Definition Logger.h:169