Medial Code Documentation
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
Logger.h File Reference

Logger.h - allowing logs with more control. More...

#include <stdio.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <stdarg.h>
#include <chrono>
#include <stdexcept>
#include <iostream>
#include <fstream>
#include <sstream>

Go to the source code of this file.

Data Structures

class  MedLogger
 
class  MedTimer
 MedTimer - a very simple class to allow very easy time measures. More...
 
class  MedProgress
 class to print progress of long process - multithreaded or not by time interval More...
 

Macros

#define LOG_APP   0
 user apps section
 
#define LOG_DEF   1
 general default section
 
#define LOG_INFRA   2
 
#define LOG_REP   3
 
#define LOG_INDEX   4
 
#define LOG_DICT   5
 
#define LOG_SIG   6
 
#define LOG_CONVERT   7
 
#define LOG_MED_UTILS   8
 
#define LOG_MEDMAT   9
 
#define LOG_MEDIO   10
 
#define LOG_DATA_STRUCTURES   11
 
#define LOG_MEDALGO   12
 
#define LOG_MEDFEAT   13
 
#define LOG_MEDSTAT   14
 
#define LOG_REPCLEANER   15
 
#define LOG_FTRGNRTR   16
 
#define LOG_CV   17
 
#define LOG_FEATCLEANER   18
 
#define LOG_VALCLNR   19
 
#define MED_SAMPLES_CV   20
 
#define LOG_FEAT_SELECTOR   21
 
#define LOG_SMPL_FILTER   22
 
#define LOG_SRL   23
 
#define LOG_MED_MODEL   24
 
#define LOG_REPTYPE   25
 
#define MAX_LOG_SECTION   26
 
#define NO_LOG_LEVEL   0
 logs get printed if their given level (which can be different for different code sections)
is > log level in levels.
 
#define MIN_LOG_LEVEL   0
 
#define DEBUG_LOG_LEVEL   3
 
#define LOG_DEF_LEVEL   5
 
#define MAX_LOG_LEVEL   10
 
#define VERBOSE_LOG_LEVEL   10
 
#define MEDLOG(Section, Level, fmt, ...)   global_logger.log(Section,Level,fmt, ##__VA_ARGS__)
 LOG() - all print options : section and level.
 
#define MDBG(Level, fmt, ...)   global_logger.log(LOCAL_SECTION,Level,fmt, ##__VA_ARGS__)
 MDBG() - use LOCAL_SECTION, Level is given.
 
#define MLOG(fmt, ...)   global_logger.log(LOCAL_SECTION, LOCAL_LEVEL, fmt, ##__VA_ARGS__)
 MLOG() - use LOCAL_SECTION and LOCAL_LEVEL.
 
#define MLOG_V(fmt, ...)   global_logger.log(LOCAL_SECTION, VERBOSE_LOG_LEVEL, fmt, ##__VA_ARGS__)
 MLOG_V() - use LOCAL_SECTION and VERBOSE_LOG_LEVEL.
 
#define MLOG_D(fmt, ...)   global_logger.log(LOCAL_SECTION, DEBUG_LOG_LEVEL, fmt, ##__VA_ARGS__)
 MLOG_D() - use LOCAL_SECTION and DEBUG_LOG_LEVEL.
 
#define MERR(fmt, ...)   global_logger.log(LOCAL_SECTION, MAX_LOG_LEVEL, fmt, ##__VA_ARGS__)
 MERR() - use LOCAL_SECTION , always print.
 
#define MWARN(fmt, ...)   global_logger.log(LOCAL_SECTION, MAX_LOG_LEVEL-1, fmt, ##__VA_ARGS__)
 MWARN - use LOCAL_SECTION and one less than MAX level (used for MERR), so that we can easily skip them.
 
#define MOUT(fmt, ...)   global_logger.out(fmt, ##__VA_ARGS__)
 
#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));}
 
#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");}
 
#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));}
 

Functions

void get_current_time (string &time_str)
 

Variables

vector< string > log_section_to_name
 
vector< string > log_level_to_name
 
MedLogger global_logger
 

Detailed Description

Logger.h - allowing logs with more control.

next are codes for libraries sections using Logger
Application codes should use LOG_APP as the LOCAL_SECTION code
each c file using the logger should contain at top something like:
#include "Logger/Logger/Logger.h"
#define LOCAL_SECTION LOG_APP
#define LOCAL_LEVEL LOG_DEF_LEVEL
extern MedLogger global_logger;

specific sections should use the section code instead of LOG_APP .
LOCAL_LEVEL can be changed to something else to allow more or less verbal logs.

Macro Definition Documentation

◆ NO_LOG_LEVEL

#define NO_LOG_LEVEL   0

logs get printed if their given level (which can be different for different code sections)
is > log level in levels.


this means that min level never be printed, and max level is always printed