log Subroutine

private subroutine log(self, level, message, module, procedure)

internal subroutines that processes the message and filters it according to the verbosity level set by the user or the default this is a private subroutine so it is not exposed to the user

Type Bound

logger_type

Arguments

Type IntentOptional Attributes Name
class(logger_type), intent(in) :: self
character(len=*), intent(in) :: level
character(len=*), intent(in) :: message
character(len=*), intent(in), optional :: module
character(len=*), intent(in), optional :: procedure

Calls

proc~~log~~CallsGraph proc~log logger_type%log proc~write_log_line write_log_line proc~log->proc~write_log_line

Variables

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

Source Code

   subroutine log(self, level, message, module, procedure)
      !! internal subroutines that processes the message and filters it according to
      !! the verbosity level set by the user or the default
      !! this is a private subroutine so it is not exposed to the user
      class(logger_type), intent(in) :: self
      character(*), intent(in) :: level
      character(*), intent(in) :: message
      character(*), intent(in), optional :: module, procedure

      integer(default_int) :: log_level_value

      select case (trim(level))
      case ("DEBUG")
         log_level_value = debug_level
      case ("VERBOSE")
         log_level_value = verbose_level
      case ("INFO")
         log_level_value = info_level
      case ("WARNING")
         log_level_value = warning_level
      case ("PERFORMANCE")
         log_level_value = performance_level
      case ("ERROR")
         log_level_value = error_level
      case default
         write (*, *) 'ERROR: Invalid log level "', trim(level), '"'
         return
      end select

      ! Console logging
      if (self%log_level >= log_level_value) then
         call write_log_line(stdout, level, message, module, procedure)
      end if

      ! File logging
      if (self%log_file_open .and. self%log_file_level >= log_level_value) then
         call write_log_line(self%log_file_unit, level, message, module, procedure)
      end if

   end subroutine log