logger_t Derived Type

type, private :: logger_t


Contents

Source Code


Components

TypeVisibility AttributesNameInitial
character(len=:), public, allocatable:: fn

Name of the log file

integer, public :: fu =huge(0)

Unit number of the log file

logical, public :: is_open =.false.

Is the log file open for writing? {T/F}


Type-Bound Procedures

procedure, public :: init => logger_init

  • private subroutine logger_init(this, fn, use_stdout)

    Initializes a logger.

    Arguments

    Type IntentOptional AttributesName
    class(logger_t), intent(out) :: this

    A logger_t instance

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

    Name of the log file. If use_stdout is true, fn is ignored.

    logical, intent(in) :: use_stdout

    Write all log messages to stdout rather than a file on disk? {T/F}

procedure, public :: finish => logger_finish

  • private subroutine logger_finish(this)

    Cleanup routine for a logger_t instance.

    Arguments

    Type IntentOptional AttributesName
    class(logger_t), intent(inout) :: this

    A logger_t instance

procedure, public :: log_msg => logger_log_msg

  • private subroutine logger_log_msg(this, msg)

    Write a message to the log file.

    Arguments

    Type IntentOptional AttributesName
    class(logger_t), intent(in) :: this

    A logger_t instance

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

    Message to write to the log file

Source Code

type logger_t
    character(len=:), allocatable :: fn
        !! Name of the log file
    integer :: fu = huge(0)
        !! Unit number of the log file
    logical :: is_open = .false.
        !! Is the log file open for writing? {T/F}
    contains
        procedure :: init => logger_init
        procedure :: finish => logger_finish
        procedure :: log_msg => logger_log_msg
end type logger_t