ArvernOS
Loading...
Searching...
No Matches
logging.h File Reference

This is the general kernel logging module. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdio.h>
#include <time/timer.h>
Include dependency graph for logging.h:
This graph shows which files directly or indirectly include this file:

Data Structures

struct  log_context_t

Macros

#define LOGGING_BUFSIZE   4096
 Size of the kernel log ring buffer. Must be a power of two.
#define __LOG_TIMESTAMP_FORMAT   "[%3" PRIu64 ".%03" PRIu64 "%03" PRIu64 "] "
#define __LOG_STREAM(time_us, ctx, level, format, ...)
 Writes one log line to the structured logger.
#define __LOG(_level, prefix, format, ...)
 Writes one log line, using the same timestamp for the whole message.

Functions

void logging_stream_output (char c, void *arg)
void logging_buffer_read (char *buf, size_t size, uint64_t offset)

Variables

bool kernel_boot_complete

Detailed Description

This is the general kernel logging module.

In release mode, the logging levels available are:

  • INFO
  • WARN

In debug mode, the following additional logging levels are available:

  • DEBUG: enabled by default but can be disabled with ENABLE_KERNEL_DEBUG set to 0.

Each kernel module should ideally have its own logging header that depends on this one. The main use case is to have more configurable loggers that can be enabled/disabled depending on the needs.

Macro Definition Documentation

◆ __LOG_TIMESTAMP_FORMAT

#define __LOG_TIMESTAMP_FORMAT   "[%3" PRIu64 ".%03" PRIu64 "%03" PRIu64 "] "

Timestamp prefix ([seconds.microseconds]) for the logger. The seconds are right-aligned on 3 characters and the fractional part is zero-padded to 6 digits.

Function Documentation

◆ logging_buffer_read()

void logging_buffer_read ( char * buf,
size_t size,
uint64_t offset )

Reads from the kernel log ring buffer.

Parameters
bufdestination buffer.
sizebuffer size in bytes.
offsetbyte offset into the available log data.

◆ logging_stream_output()

void logging_stream_output ( char c,
void * arg )

This function is used to output logs.

Parameters
ca character to print
argoptional argument, either a log_context_t or NULL.

Variable Documentation

◆ kernel_boot_complete

bool kernel_boot_complete
extern

Whether the kernel has finished booting. Until then, logs are written to both the serial port and the screen.