pic_pure_logger Module

Pure-compatible deferred logger for PIC. Messages are buffered and flushed after the pure call chain returns.


Uses

  • module~~pic_pure_logger~~UsesGraph module~pic_pure_logger pic_pure_logger module~pic_logger pic_logger module~pic_pure_logger->module~pic_logger module~pic_types pic_types module~pic_pure_logger->module~pic_types module~pic_logger->module~pic_types module~pic_global_definitions pic_global_definitions module~pic_logger->module~pic_global_definitions iso_c_binding iso_c_binding module~pic_types->iso_c_binding iso_fortran_env iso_fortran_env module~pic_types->iso_fortran_env module~pic_global_definitions->module~pic_types

Variables

Type Visibility Attributes Name Initial
integer(kind=default_int), public, parameter :: max_log_entries = 64

Maximum number of log entries a buffer can hold

integer(kind=default_int), private, parameter :: max_label_len = 16

Maximum length of a level label

integer(kind=default_int), private, parameter :: max_message_len = 256

Maximum length of a log message

integer(kind=default_int), private, parameter :: max_name_len = 64

Maximum length of a module or procedure name


Derived Types

type, public ::  log_buffer_type

Buffer that accumulates log entries inside pure code. Pass as intent(inout) through pure call chains, then flush with flush_log_buffer once back in impure context.

Components

Type Visibility Attributes Name Initial
integer(kind=default_int), public :: count = 0

Number of entries currently stored

type(log_entry_type), public :: entries(max_log_entries)
integer(kind=default_int), public :: overflow = 0

Number of entries dropped because the buffer was full

integer(kind=default_int), public :: truncated = 0

Number of entries where message or names were truncated

type, public ::  log_entry_type

A single deferred log entry

Components

Type Visibility Attributes Name Initial
logical, public :: has_module = .false.
logical, public :: has_procedure = .false.
character(len=max_label_len), public :: level = ' '
character(len=max_message_len), public :: message = ' '
character(len=max_name_len), public :: module_name = ' '
character(len=max_name_len), public :: procedure_name = ' '
logical, public :: truncated = .false.

True if the message or names exceeded their max length


Subroutines

public pure subroutine clear_log_buffer(buf)

Reset the buffer to empty. Call after flushing if you want to reuse it.

Arguments

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

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.

Read more…

Arguments

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

public pure subroutine pure_debug(buf, message, module, procedure)

Buffer a debug-level message

Arguments

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

public pure subroutine pure_error(buf, message, module, procedure)

Buffer an error-level message

Arguments

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

public pure subroutine pure_info(buf, message, module, procedure)

Buffer an info-level message

Arguments

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

public pure subroutine pure_knowledge(buf, message, module, procedure)

Buffer a knowledge-level message

Arguments

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

public pure subroutine pure_performance(buf, message, module, procedure)

Buffer a performance-level message

Arguments

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

public pure subroutine pure_verbose(buf, message, module, procedure)

Buffer a verbose-level message

Arguments

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

public pure subroutine pure_warning(buf, message, module, procedure)

Buffer a warning-level message

Arguments

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

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

private subroutine dispatch(logger, entry)

Route a buffered entry to the appropriate logger method

Arguments

Type IntentOptional Attributes Name
type(logger_type), intent(in) :: logger
type(log_entry_type), intent(in) :: entry