An object to handle output of information about the executing program to the terminal and to a log-file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
|
integer, | intent(in), | optional | :: | stdout_threshold | Threshold priority, at and above which messages will be
written to standard out. Defaults to |
|
integer, | intent(in), | optional | :: | logfile_threshold | Threshold priority, at and above which messages will be
written to the log file. Defaults to |
Closes the log-file of this logger object.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(logger), | intent(inout) | :: | this |
Write a message of a given priority to the appropriate location(s)
Write the provided message to STDERR, STDOUT, and/or a log-file, based on its priority level.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(logger), | intent(in) | :: | this | |||
character(len=*), | intent(in) | :: | source | The name of the procedure which produced the error |
||
integer, | intent(in) | :: | priority | The importance of the message, determining where it will be written. |
||
character(len=*), | intent(in) | :: | message | The information to be written. |
Write debug information
Writes debug information to STDERR, STDOUT, and/or a log-file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(logger), | intent(in) | :: | this | |||
character(len=*), | intent(in) | :: | source | The name of the procedure which produced the error |
||
character(len=*), | intent(in) | :: | message | The information to be written. |
Write trivial run-time information
Writes unimportant run-time information to STDERR, STDOUT, and/or a log-file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(logger), | intent(in) | :: | this | |||
character(len=*), | intent(in) | :: | source | The name of the procedure which produced the error |
||
character(len=*), | intent(in) | :: | message | The information to be written. |
Write run-time information
Writes run-time information to STDERR, STDOUT, and/or a log-file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(logger), | intent(in) | :: | this | |||
character(len=*), | intent(in) | :: | source | The name of the procedure which produced the error |
||
character(len=*), | intent(in) | :: | message | The information to be written. |
Write warning message
Writes warning information to STDERR, STDOUT, and/or a log-file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(logger), | intent(in) | :: | this | |||
character(len=*), | intent(in) | :: | source | The name of the procedure which produced the error |
||
character(len=*), | intent(in) | :: | message | The information to be written. |
Write error message
Writes error information to STDERR, STDOUT, and/or a log-file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(logger), | intent(in) | :: | this | |||
character(len=*), | intent(in) | :: | source | The name of the procedure which produced the error |
||
character(len=*), | intent(in) | :: | message | The information to be written. |
Write notification of fatal error
Writes fatal information to STDERR, STDOUT, and/or a log-file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(logger), | intent(in) | :: | this | |||
character(len=*), | intent(in) | :: | source | The name of the procedure which produced the error |
||
character(len=*), | intent(in) | :: | message | The information to be written. |
Closes the log-file
Closes the log-file of this logger object. Destroys only the logger object, not the output.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(logger), | intent(inout) | :: | this |
Return .true.
if the log-file is open for writing
Returns .true.
if the log-file is open for writing.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(logger), | intent(in) | :: | this |
type, public :: logger
!* Author: Chris MacMackinc
! Date: December 2016
!
! An object to handle output of information about the executing
! program to the terminal and to a log-file.
!
private
integer :: stdout = output_unit
!! Unit corresponding to STDOUT
integer :: stderr = error_unit
!! Unit corresponding to STDERR
integer :: fileunit = closed_unit
!! Unit corresponding to log-file
character(len=:), allocatable :: logfile
!! Name of the log-file
integer :: stderr_threshold = infinity
!! Cutoff for which messages with greater or equal priority will
!! be written to STDERR.
integer :: stdout_threshold = infinity
!! Cutoff for which messages with greater or equal priority will
!! be written to STDOUT.
integer :: logfile_threshold = infinity
!! Cutoff for which messages with greater or equal priority will
!! be written to the log-file.
contains
procedure :: message => logger_message
!! Write a message of a given priority to the appropriate
!! location(s)
procedure :: debug => logger_debug
!! Write debug information
procedure :: trivia => logger_trivia
!! Write trivial run-time information
procedure :: info => logger_info
!! Write run-time information
procedure :: warning => logger_warning
!! Write warning message
procedure :: error => logger_error
!! Write error message
procedure :: fatal => logger_fatal
!! Write notification of fatal error
procedure :: destroy => logger_destroy
!! Closes the log-file
procedure :: is_open => logger_is_open
!! Return `.true.` if the log-file is open for writing
final :: logger_finalize
end type logger