logger Derived Type

type, public :: logger

The Logger class is used to store all the variables related to the units of files used to store or print messages during the development (debugging ) or running


Type-Bound Procedures

procedure, public :: create => create_logger

  • private subroutine create_logger(current_log)

    logger constructor

    Arguments

    Type IntentOptional Attributes Name
    class(logger) :: current_log

    a logger object

procedure, public :: destroy => destroy_logger

  • private subroutine destroy_logger(current_log)

    Logger destructor

    Arguments

    Type IntentOptional Attributes Name
    class(logger) :: current_log

    A logger object

procedure, public :: startup

  • private subroutine startup(current_log, log_file, append_)

    Subroutine to initialize a logger object

    Arguments

    Type IntentOptional Attributes Name
    class(logger) :: current_log

    A logger object

    character(len=*) :: log_file

    A character variable with the name of the file associated to the logger

    logical, intent(in), optional :: append_

    A logical (optional) variable to indicate if appending to an existing file is desired

procedure, public :: shutdown

  • private subroutine shutdown(current_log)

    Subroutine to turn-off the logger

    Arguments

    Type IntentOptional Attributes Name
    class(logger) :: current_log

    A logger object

procedure, public :: is_initialized

  • private function is_initialized(current_log) result(initialized)

    Function to check if a logger is initialized

    Arguments

    Type IntentOptional Attributes Name
    class(logger) :: current_log

    A logger object

    Return Value logical

    A logical variable

procedure, public :: message

  • private subroutine message(current_log, msg)

    Subroutine to send a message to the logger

    Arguments

    Type IntentOptional Attributes Name
    class(logger) :: current_log

    A logger object

    character(len=*) :: msg

    A character variable with the message to send to the logger

procedure, public :: write

  • private subroutine write(current_log, unit_, msg)

    Subroutine to write a message in a file associated with the logger

    Arguments

    Type IntentOptional Attributes Name
    class(logger) :: current_log

    A logger object

    integer, intent(in) :: unit_

    An integer variable with the value of the output unit

    character(len=*) :: msg

    A character variable with the message to be written in the output unit

generic, public :: configure => configure_logical, configure_integer, configure_character

  • private subroutine configure_logical(current_log, option, value)

    Subroutine to define the logger state

    Arguments

    Type IntentOptional Attributes Name
    class(logger) :: current_log

    A logger object

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

    A character variable with the name of the state to be defined

    logical, intent(in) :: value

    A logical variable

  • private subroutine configure_integer(current_log, option, value)

    Subroutine to define a logger integer state

    Arguments

    Type IntentOptional Attributes Name
    class(logger) :: current_log

    A logger object

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

    A character variable with the name of the state to be defined

    integer, intent(in) :: value

    An integer variable

  • private subroutine configure_character(current_log, option, value)

    Subroutine to define a logger character state

    Arguments

    Type IntentOptional Attributes Name
    class(logger) :: current_log

    A logger object

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

    A character variable with the name of the state to be defined

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

    A character variable

procedure, public :: get_unit

  • private function get_unit(current_log) result(logger_unit)

    Function to get the logger unit

    Arguments

    Type IntentOptional Attributes Name
    class(logger) :: current_log

    A logger object

    Return Value integer

    An integer variable with the logger unit

procedure, public :: delimiter

  • private subroutine delimiter(current_log, level)

    Subroutine that defines the delimiter in a logger repport

    Arguments

    Type IntentOptional Attributes Name
    class(logger) :: current_log

    A logger object

    character(len=*), optional :: level

    A character variable with the definition of the delimiter

procedure, public :: get_delimiter

  • private subroutine get_delimiter(current_log, level, msg)

    Subroutine to get the delimiter text

    Arguments

    Type IntentOptional Attributes Name
    class(logger) :: current_log

    A logger object

    character(len=*) :: level

    A character variable

    character(len=100) :: msg

    A character variable

procedure, public :: reset

  • private subroutine reset(current_log)

    Subroutine to reset the logger

    Arguments

    Type IntentOptional Attributes Name
    class(logger) :: current_log

    A logger object

procedure, public :: error

  • private subroutine error(current_log, message)

    Subroutine to print an error message

    Arguments

    Type IntentOptional Attributes Name
    class(logger) :: current_log

    A logger object

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

    A character varaible with the error message

Source Code

type logger 
    private
!! The Logger class is used to store all the variables related to the units of 
!! files used to store or print messages during the development (debugging ) or 
!! running
        integer :: fileunit,stdout
        logical :: activate_screen,activate_file,timestamp
        logical :: initialized,stoponerror
        character(len=NUMCHAR) :: level_string_volume,level_string_chapter,level_string_section
        character(len=NUMCHAR) :: level_string_subsection 
    contains
        procedure,public :: create => create_logger
        procedure,public :: destroy => destroy_logger
        procedure,public :: startup
        procedure,public :: shutdown
        procedure,public :: is_initialized
        procedure,public :: message
        procedure,public :: write
        procedure,private :: get_available_unit
        procedure,private :: configure_logical
        procedure,private :: configure_integer
        procedure,private :: configure_character
        generic,public :: configure => configure_logical,configure_integer,configure_character
!        generic,public :: get 
        procedure,public :: get_unit
        procedure,public :: delimiter
        procedure,public :: get_delimiter
        procedure,public :: reset
        procedure,public :: error
end type logger