FORCES
FORtran lib for Comp. Env. Sys.
|
Module providing a logging framework. More...
#include "logging.h"
Go to the source code of this file.
Modules | |
module | mo_logging |
Module providing a logging framework. | |
Functions/Subroutines | |
subroutine | mo_logging::tput (lu, code) |
write format string to given unit | |
subroutine, public | mo_logging::stput (str, code) |
generate format string | |
subroutine, public | mo_logging::log_set_output_hostname (bool) |
Set the default for hostname output. | |
subroutine, public | mo_logging::log_set_output_severity (bool) |
Set the default for severity output. | |
subroutine, public | mo_logging::log_set_output_date (bool) |
Set the default for date output. | |
subroutine, public | mo_logging::log_set_output_time (bool) |
Set time-only date format. | |
subroutine, public | mo_logging::log_set_output_fileline (bool) |
Set the default for file/line output. | |
subroutine, public | mo_logging::log_set_skip_terminal_check (bool) |
Whether or not to skip the terminal check. | |
subroutine, public | mo_logging::log_set_disable_colors (bool) |
Disable colors altogether. | |
subroutine, public | mo_logging::log_set_disable_format (bool) |
Disable formatting altogether. | |
integer function, public | mo_logging::logu (level) |
Output unit to log. | |
logical function, public | mo_logging::logp (level, only_n) |
Output this log statement or not. | |
character(len=300) function, public | mo_logging::logl (level, filename, linenum) |
Write a log lead containing level and optional info. | |
subroutine | mo_logging::strip_path (filepath, basename) |
Get base name of a file path. | |
character(len=50) function | mo_logging::log_hostname () |
Return the hostname in a 50 character string. | |
character(len=n) function | mo_logging::spaces (n) |
Return n spaces. | |
character(len=50) function | mo_logging::log_severity (level, show_colors) |
Return the severity level with colors etc in a 50 char string. | |
character(50) function | mo_logging::log_datetime () |
Return the current date, formatted nicely. | |
subroutine, public | mo_logging::log_set_config (verbose, quiet, log_output_hostname, log_force_colors, log_no_colors, log_output_date, log_output_time, log_no_format) |
Set logging configuration. | |
Variables | |
integer, parameter, public | mo_logging::num_log_levels = 7 |
1 through 7 (fatal through trace) | |
integer, parameter, public | mo_logging::log_fatal = LOG_LEVEL_FATAL_DEF |
= 1, Runtime error causing termination | |
integer, parameter, public | mo_logging::log_error = LOG_LEVEL_ERROR_DEF |
= 2, Runtime error | |
integer, parameter, public | mo_logging::log_warn = LOG_LEVEL_WARN_DEF |
= 3, Warning, but we can continue | |
integer, parameter, public | mo_logging::log_info = LOG_LEVEL_INFO_DEF |
= 4, Interesting events | |
integer, parameter, public | mo_logging::log_debug = LOG_LEVEL_DEBUG_DEF |
= 5, Detailed debug output, disable by compiling your program with -DDISABLE_LOG_DEBUG | |
integer, parameter, public | mo_logging::log_trace = LOG_LEVEL_TRACE_DEF |
= 6, Extremely detailed output, compile your program with -DENABLE_LOG_TRACE to enable | |
integer, parameter, public | mo_logging::log_subtrace = LOG_LEVEL_SUBTRACE_DEF |
= 7, More Extremely detailed output, compile your program with -DENABLE_LOG_TRACE to enable | |
integer, save, public | mo_logging::log_unit = stdout |
By default, log to stdout for level > 2. | |
integer, save, public | mo_logging::log_unit_error = stderr |
By default, log to stderr for level <= 2. | |
integer, save, public | mo_logging::minimum_log_level = LOG_INFO |
Note that more critical means a lower number. | |
logical, save, public | mo_logging::show_file_and_line = .true. |
show file name and line number in log output | |
character(len= *), parameter | mo_logging::start = achar(27) |
Control start character. | |
character(len= *), parameter | mo_logging::reset = "0" |
Control reset character. | |
character(len= *), parameter | mo_logging::bold = "1" |
Styles. | |
character(len= *), parameter | mo_logging::dimmed = "2" |
character(len= *), parameter | mo_logging::underline = "4" |
character(len= *), parameter | mo_logging::blink = "5" |
character(len= *), parameter | mo_logging::invert = "7" |
character(len= *), parameter | mo_logging::hidden = "8" |
logical, save | mo_logging::output_hostname = .false. |
logical, save | mo_logging::output_severity = .true. |
logical, save | mo_logging::output_date = .false. |
logical, save | mo_logging::output_time = .false. |
logical, save | mo_logging::output_fileline = .true. |
logical, save | mo_logging::skip_terminal_check = .false. |
logical, save | mo_logging::disable_colors = .false. |
logical, save | mo_logging::disable_format = .false. |
character(len= *), dimension(num_log_levels), parameter | mo_logging::color_codes = ["31", "31", "33", "32", "35", "36", "36"] |
These are the color codes corresponding to the loglevels above. | |
character(len= *), dimension(num_log_levels), parameter | mo_logging::style_codes = [bold, reset, reset, reset, reset, reset, reset] |
These are the styles corresponding to the loglevels above. | |
character(len= *), parameter | mo_logging::level_color = "20" |
Colors for other output. | |
Module providing a logging framework.
A simple logging framework derived from flogging (https://github.com/DaanVanVugt/flogging). To use logging you need to include logging.h
at the top of your fortran file.
Afterwards you have a list of logging routines that could be used instead of write
:
log_fatal(format)
: level 1log_error(format)
: level 2log_warn(format)
: level 3log_info(format)
: level 4log_debug(format)
: level 5log_trace(format)
: level 6log_subtrace(format)
: level 7 as required.The following example demonstrates the functionality. The mo_cli
module incorporates logger settings:
You can call the program with:
You can see all cli logger options with:
COPYING
and COPYING.LESSER
provided with this software. The complete GNU license text can also be found at http://www.gnu.org/licenses/. Definition in file mo_logging.F90.