logger_class Derived Type

type, public :: logger_class

Opaque logger class.


Type-Bound Procedures

procedure, public :: configure => logger_configure

  • private subroutine logger_configure(this, name, node_id, source, debug, ipc, blocking, no_color, verbose)

    Configures the (global) logger. The argument name is set only if it is a valid id of character set [-0-9A-Z_a-z]. The argument source shall be the name of the log source, usually the name of the calling program.

    If debug is passed and .true., log messages of level LL_DEBUG are forwarded via message queue. Otherwise, the minimum level for logs to be transmitted is LL_INFO. If ipc is passed and .true., logs are sent to the POSIX message queue of logger name. The name of the message queue is therefore /<name>. Writing to the message queue is blocking, unless blocking is passed and .false..

    The dummy argument no_color disables coloured output through ANSI escape sequences if .true.. Log messages are printed to standard error, unless verbose is passed and .false..

    Arguments

    Type IntentOptional Attributes Name
    class(logger_class), intent(inout) :: this

    Logger object.

    character(len=*), intent(in), optional :: name

    Logger name.

    character(len=*), intent(in), optional :: node_id

    Node id.

    character(len=*), intent(in), optional :: source

    Source (name of calling program).

    logical, intent(in), optional :: debug

    Forward debugging messages via IPC.

    logical, intent(in), optional :: ipc

    IPC through POSIX message queues.

    logical, intent(in), optional :: blocking

    Blocking IPC.

    logical, intent(in), optional :: no_color

    Disable ANSI colours.

    logical, intent(in), optional :: verbose

    Verbose output.

procedure, public :: get_name => logger_get_name

  • private function logger_get_name(this) result(name)

    Returns name of logger as allocatable string.

    Arguments

    Type IntentOptional Attributes Name
    class(logger_class), intent(inout) :: this

    Logger object.

    Return Value character(len=:), allocatable

    Logger name.

procedure, public :: is_ipc => logger_is_ipc

  • private function logger_is_ipc(this) result(is)

    Returns .true. if IPC is enabled.

    Arguments

    Type IntentOptional Attributes Name
    class(logger_class), intent(inout) :: this

    Logger object.

    Return Value logical

procedure, public :: out => logger_out

  • private subroutine logger_out(this, log, unit)

    Prints log message to standard error.

    Arguments

    Type IntentOptional Attributes Name
    class(logger_class), intent(inout) :: this

    Logger object.

    type(log_type), intent(inout) :: log

    Log to output.

    integer, intent(in), optional :: unit

    File unit.

generic, public :: log => log_args, log_type

  • private subroutine logger_log_args(this, level, message, source, observ, timestamp, error, escape, verbose)

    Sends a log message to the message queue (fire & forget). Only the log level is validated. An invalid level is set to LL_ERROR.

    If error is passed and E_NONE, no log is created, unless verbose is set to .true.. The passed log message is not validated, but non-printable characters are escaped, unless escape is passed and .false..

    The length of argument message is limited to LOG_MESSAGE_LEN.

    Arguments

    Type IntentOptional Attributes Name
    class(logger_class), intent(inout) :: this

    Logger object.

    integer, intent(in) :: level

    Log level.

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

    Log message.

    character(len=*), intent(in), optional :: source

    Optional source of log.

    type(observ_type), intent(inout), optional :: observ

    Optional observation data.

    character(len=*), intent(in), optional :: timestamp

    Optional timestamp of log.

    integer, intent(in), optional :: error

    Optional error code.

    logical, intent(in), optional :: escape

    Escape non-printable characters in message (.true. by default).

    logical, intent(in), optional :: verbose

    Create log if error is passed and E_NONE (.false. by default).

  • private subroutine logger_log_type(this, log)

    Sends a log data type to the message queue (send & forget). The passed log is not validated and must have id, node id, and timestamp. The receiver may decline the log if the data is invalid. The log is forwarded even if the error code is E_NONE.

    Arguments

    Type IntentOptional Attributes Name
    class(logger_class), intent(inout) :: this

    Logger object.

    type(log_type), intent(inout) :: log

    Log type.

procedure, public :: critical => logger_log_critical

  • private subroutine logger_log_critical(this, message, source, observ, timestamp, error, escape, verbose)

    Sends a critical log message to the message queue.

    Arguments

    Type IntentOptional Attributes Name
    class(logger_class), intent(inout) :: this

    Logger object.

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

    Log message.

    character(len=*), intent(in), optional :: source

    Optional source of log.

    type(observ_type), intent(inout), optional :: observ

    Optional observation data.

    character(len=*), intent(in), optional :: timestamp

    Optional timestamp of log.

    integer, intent(in), optional :: error

    Optional error code.

    logical, intent(in), optional :: escape

    Escape non-printable characters in message.

    logical, intent(in), optional :: verbose

    Create log if error is E_NONE.

procedure, public :: debug => logger_log_debug

  • private subroutine logger_log_debug(this, message, source, observ, timestamp, error, escape, verbose)

    Sends a debugging log message to the message queue.

    Arguments

    Type IntentOptional Attributes Name
    class(logger_class), intent(inout) :: this

    Logger object.

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

    Log message.

    character(len=*), intent(in), optional :: source

    Optional source of log.

    type(observ_type), intent(inout), optional :: observ

    Optional observation data.

    character(len=*), intent(in), optional :: timestamp

    Optional timestamp of log.

    integer, intent(in), optional :: error

    Optional error code.

    logical, intent(in), optional :: escape

    Escape non-printable characters in message.

    logical, intent(in), optional :: verbose

    Create log if error is E_NONE.

procedure, public :: error => logger_log_error

  • private subroutine logger_log_error(this, message, source, observ, timestamp, error, escape, verbose)

    Sends a error log message to the message queue.

    Arguments

    Type IntentOptional Attributes Name
    class(logger_class), intent(inout) :: this

    Logger object.

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

    Log message.

    character(len=*), intent(in), optional :: source

    Optional source of log.

    type(observ_type), intent(inout), optional :: observ

    Optional observation data.

    character(len=*), intent(in), optional :: timestamp

    Optional timestamp of log.

    integer, intent(in), optional :: error

    Optional error code.

    logical, intent(in), optional :: escape

    Escape non-printable characters in message.

    logical, intent(in), optional :: verbose

    Create log if error is E_NONE.

procedure, public :: info => logger_log_info

  • private subroutine logger_log_info(this, message, source, observ, timestamp, error, escape, verbose)

    Sends a info log message to the message queue.

    Arguments

    Type IntentOptional Attributes Name
    class(logger_class), intent(inout) :: this

    Logger object.

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

    Log message.

    character(len=*), intent(in), optional :: source

    Optional source of log.

    type(observ_type), intent(inout), optional :: observ

    Optional observation data.

    character(len=*), intent(in), optional :: timestamp

    Optional timestamp of log.

    integer, intent(in), optional :: error

    Optional error code.

    logical, intent(in), optional :: escape

    Escape non-printable characters in message.

    logical, intent(in), optional :: verbose

    Create log if error is E_NONE.

procedure, public :: user => logger_log_user

  • private subroutine logger_log_user(this, message, source, observ, timestamp, error, escape, verbose)

    Sends a user-defined log message to the message queue.

    Arguments

    Type IntentOptional Attributes Name
    class(logger_class), intent(inout) :: this

    Logger object.

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

    Log message.

    character(len=*), intent(in), optional :: source

    Optional source of log.

    type(observ_type), intent(inout), optional :: observ

    Optional observation data.

    character(len=*), intent(in), optional :: timestamp

    Optional timestamp of log.

    integer, intent(in), optional :: error

    Optional error code.

    logical, intent(in), optional :: escape

    Escape non-printable characters in message.

    logical, intent(in), optional :: verbose

    Create log if error is E_NONE.

procedure, public :: warning => logger_log_warning

  • private subroutine logger_log_warning(this, message, source, observ, timestamp, error, escape, verbose)

    Sends a warning log message to the message queue.

    Arguments

    Type IntentOptional Attributes Name
    class(logger_class), intent(inout) :: this

    Logger object.

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

    Log message.

    character(len=*), intent(in), optional :: source

    Optional source of log.

    type(observ_type), intent(inout), optional :: observ

    Optional observation data.

    character(len=*), intent(in), optional :: timestamp

    Optional timestamp of log.

    integer, intent(in), optional :: error

    Optional error code.

    logical, intent(in), optional :: escape

    Escape non-printable characters in message.

    logical, intent(in), optional :: verbose

    Create log if error is E_NONE.