Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | logfile | |||
character(len=*), | intent(in), | optional | :: | stderr_level | ||
character(len=*), | intent(in), | optional | :: | stdout_level | ||
character(len=*), | intent(in), | optional | :: | logfile_level |
function log_create(logfile, stderr_level, stdout_level, logfile_level) result(log)
type(logger) :: log
! Name of the log-file to which output will be written
character(len=*), intent(in) :: logfile
! Threshold priority, at and above which messages will be written to standard error.
character(len=*), intent(in), optional :: stderr_level
! Threshold priority, at and above which messages will be written to standard out.
character(len=*), intent(in), optional :: stdout_level
! Threshold priority, at and above which messages will be written to the log file.
character(len=*), intent(in), optional :: logfile_level
log%logfile = logfile
if (present(stderr_level)) log%stderr_threshold = log_str2level(stderr_level)
if (present(stdout_level)) log%stdout_threshold = log_str2level(stdout_level)
if (present(logfile_level)) log%logfile_threshold = log_str2level(logfile_level)
! open file if needed
if (log%logfile_threshold <= log_error_level) log%fileunit = open_file(logfile, 'w')
end function log_create