flush_log_buffer Subroutine

public subroutine flush_log_buffer(logger, buf)

Flush all buffered entries through the real logger, then clear the buffer. This is impure — call it once you are back outside the pure call chain.

Usage: call flush_log_buffer(global_logger, log_buf)

Arguments

Type IntentOptional Attributes Name
type(logger_type), intent(in) :: logger
type(log_buffer_type), intent(inout) :: buf

Calls

proc~~flush_log_buffer~~CallsGraph proc~flush_log_buffer flush_log_buffer proc~clear_log_buffer clear_log_buffer proc~flush_log_buffer->proc~clear_log_buffer proc~dispatch dispatch proc~flush_log_buffer->proc~dispatch proc~warning logger_type%warning proc~flush_log_buffer->proc~warning proc~dispatch->proc~warning proc~debug logger_type%debug proc~dispatch->proc~debug proc~error logger_type%error proc~dispatch->proc~error proc~info logger_type%info proc~dispatch->proc~info proc~knowledge logger_type%knowledge proc~dispatch->proc~knowledge proc~performance logger_type%performance proc~dispatch->proc~performance proc~verbose logger_type%verbose proc~dispatch->proc~verbose

Variables

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

Source Code

   subroutine flush_log_buffer(logger, buf)
      !! Flush all buffered entries through the real logger, then clear the buffer.
      !! This is impure — call it once you are back outside the pure call chain.
      !!
      !! Usage:
      !!   call flush_log_buffer(global_logger, log_buf)
      !!
      type(logger_type), intent(in) :: logger
      type(log_buffer_type), intent(inout) :: buf

      integer(default_int) :: i

      do i = 1, buf%count
         call dispatch(logger, buf%entries(i))
      end do

      if (buf%truncated > 0) then
         call logger%warning("Pure log buffer: some messages were truncated due to length limits")
      end if

      if (buf%overflow > 0) then
         call logger%warning("Pure log buffer overflow: some messages were dropped")
      end if

      call clear_log_buffer(buf)
   end subroutine flush_log_buffer