|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_UTILS_CORE_LOGGING_H_
2 #define GENESIS_UTILS_CORE_LOGGING_H_
66 # define LOG_LEVEL_MAX genesis::utils::Logging::kDebug4
75 # define LOG_LEVEL_MAX genesis::utils::Logging::kDebug4
80 #define GENESIS_LOG(level) \
81 if (level > LOG_LEVEL_MAX) ; \
82 else if (level > genesis::utils::Logging::max_level()) ; \
83 else genesis::utils::Logging().get(__FILE__, __LINE__, GENESIS_FUNC, level)
86 #define GENESIS_LOG_DETAILS(level, ...) \
87 if (level > LOG_LEVEL_MAX) ; \
88 else if (level > genesis::utils::Logging::max_level()) ; \
89 else genesis::utils::Logging().get(__FILE__, __LINE__, GENESIS_FUNC, level, {__VA_ARGS__})
94 #define LOG_ERR GENESIS_LOG(genesis::utils::Logging::kError)
97 #define LOG_WARN GENESIS_LOG(genesis::utils::Logging::kWarning)
100 #define LOG_INFO GENESIS_LOG(genesis::utils::Logging::kInfo)
103 #define LOG_MSG GENESIS_LOG(genesis::utils::Logging::kMessage)
106 #define LOG_MSG1 GENESIS_LOG(genesis::utils::Logging::kMessage1)
109 #define LOG_MSG2 GENESIS_LOG(genesis::utils::Logging::kMessage2)
112 #define LOG_MSG3 GENESIS_LOG(genesis::utils::Logging::kMessage3)
115 #define LOG_MSG4 GENESIS_LOG(genesis::utils::Logging::kMessage4)
118 #define LOG_DBG GENESIS_LOG(genesis::utils::Logging::kDebug)
121 #define LOG_DBG1 GENESIS_LOG(genesis::utils::Logging::kDebug1)
124 #define LOG_DBG2 GENESIS_LOG(genesis::utils::Logging::kDebug2)
127 #define LOG_DBG3 GENESIS_LOG(genesis::utils::Logging::kDebug3)
130 #define LOG_DBG4 GENESIS_LOG(genesis::utils::Logging::kDebug4)
143 #define LOG_BOLD GENESIS_LOG_DETAILS(genesis::utils::Logging::kNone, \
144 false, false, false, false, false, false, false, false, false)
154 #define LOG_TIME GENESIS_LOG_DETAILS(genesis::utils::Logging::kDebug, \
155 false, false, false, false , true, false, false, false, false)
165 #define LOG_SCOPE_LEVEL(level) \
166 genesis::utils::LoggingScopeLevel genesis_logging_scope_level_temp_object(level);
232 #define LOG_PROG( value, quantity ) \
233 if( genesis::utils::Logging::kProgress > LOG_LEVEL_MAX ) ; \
234 else if( genesis::utils::Logging::kProgress > genesis::utils::Logging::max_level() ) ; \
235 else if( (long) genesis::utils::logging_progress_value(value) % \
236 (((long) (quantity) * genesis::utils::Logging::report_percentage() / 100) > 0 ? \
237 ((long) (quantity) * genesis::utils::Logging::report_percentage() / 100) : 1) != 0 ) ; \
238 else genesis::utils::Logging().get(__FILE__, __LINE__, GENESIS_FUNC, genesis::utils::Logging::kProgress) << \
239 (int) round(100.0 * (double) genesis::utils::logging_progress_value() / ((quantity) > 0 ? (quantity) : 1)) << "% "
272 bool v_count,
bool v_date,
bool v_time,
bool v_runtime,
bool v_rundiff,
273 bool v_file,
bool v_line,
bool v_function,
bool v_level
321 bool function =
false;
462 std::ostringstream&
get (
463 const std::string& file,
const int line,
const std::string&
function,
466 std::ostringstream&
get (
467 const std::string& file,
const int line,
const std::string&
function,
524 static inline void log_info (
const std::string& msg)
610 static std::vector<std::unique_ptr<std::ofstream>>
fstreams_;
675 #endif // include guard
#define LOG_INFO
Log an info message. See genesis::utils::LoggingLevel.
static void log_message_2(const std::string &msg)
POD stuct containing the settings for which information is included with each logging message.
#define LOG_MSG
Log an info message. See genesis::utils::LoggingLevel.
#define LOG_MSG1
Log an info message. See genesis::utils::LoggingLevel.
static std::vector< std::unique_ptr< std::ofstream > > fstreams_
static void log_warning(const std::string &msg)
@ kWarning
Warnings if somthing went wront, but program can continue. See LOG_WARN.
static int report_percentage_
static void log_message_4(const std::string &msg)
~Logging()
Destructor that is invoked at the end of each log line and does the actual output.
bool date
Include the current date.
#define LOG_MSG2
Log an info message. See genesis::utils::LoggingLevel.
std::ostringstream & get(const std::string &file, const int line, const std::string &function, const LoggingLevel level)
Getter for the singleton instance of log, is called by the standard macros.
static void log_message_1(const std::string &msg)
static std::vector< std::ostream * > ostreams_
static void log_message(const std::string &msg)
static void clear()
Remove all output streams, so that nothing is logged any more.
bool count
Include a counter of how many messages have been logged so far.
@ kInfo
Infos, for example when a file was written. See LOG_INFO.
static void log_message_3(const std::string &msg)
@ kMessage1
Message with level 1. See LOG_MSG1.
bool level
Include the level (e.g. Info, Debug) of the message.
static clock_t last_clock_
@ kProgress
Progess, used in long executing functions. See LOG_PROG.
bool file
Include the filename where the log message was generated.
Provides some valuable additions to STD.
long logging_progress_value(long value=-1)
Hack function to make sure that the value arugment in LOG_PROG is only evaluated once.
static LoggingDetails details
Settings for which information is included with each log message. See LoggingDetails for usage.
#define LOG_DBG2
Log a debug message. See genesis::utils::LoggingLevel.
bool function
Include the function name where the log message was generated.
@ kDebug4
Debugging message with indent level 4. See LOG_DBG4.
LoggingScopeLevel(Logging::LoggingLevel scope_level)
LoggingLevel
Levels of severity used for logging.
static LoggingLevel max_level()
Get the highest log level that is reported.
@ kDebug3
Debugging message with indent level 3. See LOG_DBG3.
#define LOG_WARN
Log a warning. See genesis::utils::LoggingLevel.
#define LOG_ERR
Log an error. See genesis::utils::LoggingLevel.
static std::string level_to_string(const LoggingLevel level)
Return a string representation of a log level.
#define LOG_MSG3
Log an info message. See genesis::utils::LoggingLevel.
Class that sets the Logging Level to a value von construction and set it back on destruction....
static void log_debug_2(const std::string &msg)
static int report_percentage()
Get the current percentage for reporting LOG_PROG messages.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
@ kDebug2
Debugging message with indent level 2. See LOG_DBG2.
bool line
Include the line of the file where the log message was generated.
@ kMessage2
Message with level 2. See LOG_MSG2.
bool runtime
Include the current run time of the program in sec.
static void log_to_file(const std::string &fn)
Add an output file to which log messages are written.
static void log_to_stream(std::ostream &os)
Add an output stream to which log messages are written.
#define LOG_DBG1
Log a debug message. See genesis::utils::LoggingLevel.
bool time
Include the current time.
@ kMessage
Basic message. See LOG_MSG.
static LoggingLevel max_level_
Logging class with easy and fast usage.
static void log_info(const std::string &msg)
static void log_debug_1(const std::string &msg)
@ kMessage3
Message with level 3. See LOG_MSG3.
static void log_to_stdout()
Add stdout as output stream to which log messages are written.
#define LOG_MSG4
Log an info message. See genesis::utils::LoggingLevel.
@ kNone
Special messages that are always logged, e.g. program header.
@ kError
Errors, usually non-recoverable. See LOG_ERR.
static void log_debug_4(const std::string &msg)
@ kDebug
Basic debugging message. See LOG_DBG.
#define LOG_DBG3
Log a debug message. See genesis::utils::LoggingLevel.
#define LOG_DBG
Log a debug message. See genesis::utils::LoggingLevel.
static void log_debug_3(const std::string &msg)
static void log_error(const std::string &msg)
static std::string debug_indent
Indention string for Debug Levels 1-4.
#define LOG_DBG4
Log a debug message. See genesis::utils::LoggingLevel.
Logging & operator=(const Logging &)=delete
@ kDebug1
Debugging message with indent level 1 (e.g. for loops). See LOG_DBG1.
bool rundiff
Include the run time difference to the last log message in sec.
static void log_debug(const std::string &msg)
@ kMessage4
Message with level 4. See LOG_MSG4.
LoggingDetails(bool v_count, bool v_date, bool v_time, bool v_runtime, bool v_rundiff, bool v_file, bool v_line, bool v_function, bool v_level)