logger Module

Provides five log levels (SILENT, ERROR, WARN, INFO, DEBUG) and routes messages to stdout, an optional log file, or both. The module is safe to use before log_init is called: it defaults to INFO level with no file.

Level constants (use these in namelist verbosity field): LOGLVL_SILENT = 0 — suppress all output LOGLVL_ERROR = 1 — errors only LOGLVL_WARN = 2 — warnings and errors LOGLVL_INFO = 3 — normal operational messages (default) LOGLVL_DEBUG = 4 — developer diagnostics

Typical usage in the driver: @code call log_init(cfg % verbosity, cfg % log_file) call log_info('config: loaded "input.nml"') call log_warn('reconstruction: char_proj ignored on FDS path') call log_finalize() @endcode



Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: LOGLVL_SILENT = 0

Log level constants. Higher value = more verbose. Note: names use LOGLVL_ prefix to avoid case-insensitive clash with the log_error / log_warn / log_info / log_debug subroutines.

integer, public, parameter :: LOGLVL_ERROR = 1
integer, public, parameter :: LOGLVL_WARN = 2
integer, public, parameter :: LOGLVL_INFO = 3
integer, public, parameter :: LOGLVL_DEBUG = 4
integer, private :: log_verbosity = LOGLVL_INFO
integer, private :: log_file_unit = -1
logical, private :: log_file_open = .false.

Subroutines

public subroutine log_init(verbosity, log_file)

Initialise the logger: set verbosity level and optionally open a log file.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: verbosity

Threshold level (LOGLVL_SILENT … LOGLVL_DEBUG).

character(len=*), intent(in) :: log_file

Path for the log file. Empty string disables file logging.

public subroutine log_finalize()

Close the log file and reset file-logging state.

Arguments

None

public subroutine log_error(msg)

Emit an ERROR-level message.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: msg

public subroutine log_warn(msg)

Emit a WARN-level message.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: msg

public subroutine log_info(msg)

Emit an INFO-level message.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: msg

public subroutine log_debug(msg)

Emit a DEBUG-level message.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: msg

private subroutine emit(tag, msg, threshold)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: tag
character(len=*), intent(in) :: msg
integer, intent(in) :: threshold