subroutine log_message(source, level, message, log, i1, i2, int, real, ints, reals)
! Write the provided message to STDERR, STDOUT, and/or a log-file, based on level.
! The name of the procedure which produced the error
character(len=*), intent(in) :: source
! The importance of the message, determining where it will be written.
integer, intent(in) :: level
character(len=*), intent(in) :: message
! optional logger, defaults to master_log
type(logger), intent(in), optional :: log
! optional index, single int/real or 1D arrays to append to message
integer, intent(in), optional :: i1, i2, int, ints(:)
real(dp), intent(in), optional :: real, reals(:)
type(logger) :: lg
integer :: cl = 0
if (present(log)) then
lg = log
else
lg = master_log
end if
if (level >= lg%stderr_threshold) then
if (lg%stderr == lg%stdout) cl = log_in_progess
call log_write(lg%stderr, &
log_format_message(level, source, message, datetime=.false.), &
i1, i2, int, real, ints, reals, clear=cl)
else if (level >= lg%stdout_threshold) then
call log_write(lg%stdout, &
log_format_message(level, source, message, datetime=.false.), &
i1, i2, int, real, ints, reals, clear=log_in_progess)
end if
if (lg%fileunit > 0 .and. level >= lg%logfile_threshold) then
call log_write(lg%fileunit, &
log_format_message(level, source, message, colour=.false.), &
i1, i2, int, real, ints, reals)
end if
end subroutine log_message