logger_mod Module

Provides routines for printing different types of messages to standard out, standard error, and/or a log file.



Variables

TypeVisibility AttributesNameInitial
integer, public, parameter:: debug =10

Priority level for output only useful for debugging

integer, public, parameter:: trivia =20

Priority level for output which may be useful but is very detailed or not especially important.

integer, public, parameter:: info =30

Priority level for output generated by the normal execution of the program.

integer, public, parameter:: warning =40

Priority level for output which indicates some part of the program is not behaving as it ideally should.

integer, public, parameter:: error =50

Priority level for output which indicates an error has occurred which will affect the continued execution of the program.

integer, public, parameter:: fatal =60

Priority level for output which notifies the user than a serious error has occured which will result in the immediate termination of the program.

type(logger), public :: master_logger

The main logger object for a program to use. Must be initialised in the main program with a call to logger_init.


Interfaces

public interface logger

  • private function constructor(logfile, stderr_threshold, stdout_threshold, logfile_threshold) result(this)

    Arguments

    Type IntentOptional AttributesName
    character(len=*), intent(in) :: logfile

    Name of the log-file to which output will be written

    integer, intent(in), optional :: stderr_threshold

    Threshold priority, at and above which messages will be written to standard error. Defaults to error.

    integer, intent(in), optional :: stdout_threshold

    Threshold priority, at and above which messages will be written to standard out. Defaults to info.

    integer, intent(in), optional :: logfile_threshold

    Threshold priority, at and above which messages will be written to the log file. Defaults to trivia.

    Return Value type(logger)


Derived Types

type, public :: logger

An object to handle output of information about the executing program to the terminal and to a log-file.

Constructor

private function constructor(logfile, stderr_threshold, stdout_threshold, logfile_threshold)

Finalizations Procedures

final :: logger_finalize

Type-Bound Procedures

procedure, public :: message => logger_message

Write a message of a given priority to the appropriate location(s)

procedure, public :: debug => logger_debug

Write debug information

procedure, public :: trivia => logger_trivia

Write trivial run-time information

procedure, public :: info => logger_info

Write run-time information

procedure, public :: warning => logger_warning

Write warning message

procedure, public :: error => logger_error

Write error message

procedure, public :: fatal => logger_fatal

Write notification of fatal error

procedure, public :: destroy => logger_destroy

Closes the log-file

procedure, public :: is_open => logger_is_open

Return .true. if the log-file is open for writing


Subroutines

public subroutine logger_init(logfile, stderr_threshold, stdout_threshold, logfile_threshold)

Author
Chris MacMackin
Date
December 2016

Initalises the master logging object. This subroutine must be called before the master logger is used. It should only be called once.

Arguments

Type IntentOptional AttributesName
character(len=*), intent(in) :: logfile

Name of the log-file to which output will be written

integer, intent(in), optional :: stderr_threshold

Threshold priority, at and above which messages will be written to standard error. Defaults to error.

integer, intent(in), optional :: stdout_threshold

Threshold priority, at and above which messages will be written to standard out. Defaults to info.

integer, intent(in), optional :: logfile_threshold

Threshold priority, at and above which messages will be written to the log file. Defaults to trivia.