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 | Intent | Optional | 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 |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=default_int), | private | :: | idx | ||||
| logical, | private | :: | was_truncated |
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