configure_file_output Subroutine

private subroutine configure_file_output(self, filename, level)

Configure the logger to file to be a certain verbosity level

Usage: call my_logger%configure_file_output(level)

Where level can be a number according to the level struct or can be loaded from the level struct to be

debug_level = 10, &

verbose_level = 9, &

info_level = 8, &

performance_level = 7, &

warning_level = 6, &

error_level = 5

Type Bound

logger_type

Arguments

Type IntentOptional Attributes Name
class(logger_type), intent(inout) :: self
character(len=*), intent(in) :: filename
integer(kind=default_int), intent(in), optional :: level

Calls

proc~~configure_file_output~~CallsGraph proc~configure_file_output logger_type%configure_file_output proc~close_log_file logger_type%close_log_file proc~configure_file_output->proc~close_log_file

Variables

Type Visibility Attributes Name Initial
integer(kind=default_int), private :: ios

Source Code

   subroutine configure_file_output(self, filename, level)
      !! Configure the logger to file to be a certain verbosity level
      !!
      !! Usage: call my_logger%configure_file_output(level)
      !!
      !! Where level can be a number according to the level struct
      !! or can be loaded from the level struct to be
      !!
      !! debug_level = 10, &
      !!
      !! verbose_level = 9, &
      !!
      !! info_level = 8, &
      !!
      !! performance_level = 7, &
      !!
      !! warning_level = 6, &
      !!
      !! error_level = 5
      !!
      class(logger_type), intent(inout) :: self
      character(*), intent(in) :: filename
      integer(default_int), intent(in), optional :: level

      integer(default_int) :: ios

      if (self%log_file_open) call self%close_log_file()

      open (unit=logfile_unit, file=trim(filename), status="replace", action="write", iostat=ios)
      if (ios /= 0) then
         write (*, *) "ERROR: Failed to open log file: ", trim(filename)
         return
      end if

      self%log_file_unit = logfile_unit
      self%log_file_open = .true.
      if (present(level)) self%log_file_level = level
   end subroutine configure_file_output