buffer_message Subroutine

private pure subroutine buffer_message(buf, level, message, module, procedure)

Core buffering routine — appends a log entry to the buffer. If the buffer is full, increments the overflow counter. If a message or name exceeds its max length, it is truncated and the entry is flagged.

Arguments

Type IntentOptional Attributes Name
type(log_buffer_type), intent(inout) :: buf
character(len=*), intent(in) :: level
character(len=*), intent(in) :: message
character(len=*), intent(in), optional :: module
character(len=*), intent(in), optional :: procedure

Called by

proc~~buffer_message~~CalledByGraph proc~buffer_message buffer_message proc~pure_debug pure_debug proc~pure_debug->proc~buffer_message proc~pure_error pure_error proc~pure_error->proc~buffer_message proc~pure_info pure_info proc~pure_info->proc~buffer_message proc~pure_knowledge pure_knowledge proc~pure_knowledge->proc~buffer_message proc~pure_performance pure_performance proc~pure_performance->proc~buffer_message proc~pure_verbose pure_verbose proc~pure_verbose->proc~buffer_message proc~pure_warning pure_warning proc~pure_warning->proc~buffer_message

Variables

Type Visibility Attributes Name Initial
integer(kind=default_int), private :: idx
logical, private :: was_truncated

Source Code

   pure subroutine buffer_message(buf, level, message, module, procedure)
      !! Core buffering routine — appends a log entry to the buffer.
      !! If the buffer is full, increments the overflow counter.
      !! If a message or name exceeds its max length, it is truncated
      !! and the entry is flagged.
      type(log_buffer_type), intent(inout) :: buf
      character(*), intent(in) :: level, message
      character(*), intent(in), optional :: module, procedure

      integer(default_int) :: idx
      logical :: was_truncated

      if (buf%count >= max_log_entries) then
         buf%overflow = buf%overflow + 1
         return
      end if

      buf%count = buf%count + 1
      idx = buf%count
      was_truncated = .false.

      buf%entries(idx)%level = level
      buf%entries(idx)%message = message
      if (len(message) > max_message_len) was_truncated = .true.

      if (present(module)) then
         buf%entries(idx)%module_name = module
         buf%entries(idx)%has_module = .true.
         if (len(module) > max_name_len) was_truncated = .true.
      end if

      if (present(procedure)) then
         buf%entries(idx)%procedure_name = procedure
         buf%entries(idx)%has_procedure = .true.
         if (len(procedure) > max_name_len) was_truncated = .true.
      end if

      if (was_truncated) then
         buf%entries(idx)%truncated = .true.
         buf%truncated = buf%truncated + 1
      end if
   end subroutine buffer_message