PatchworkOS  19e446b
A non-POSIX operating system.
Loading...
Searching...
No Matches
Logging Subsystem

Kernel logging and debugging. More...

Collaboration diagram for Logging Subsystem:

Detailed Description

Kernel logging and debugging.

Modules

 Panic
 Panic handling.
 
 Screen
 Screen logging.
 

Macros

#define LOG_MAX_BUFFER   0x1000
 Maximum buffer size for various logging buffers.
 
#define LOG_DEBUG(format, ...)   log_print(LOG_LEVEL_DEBUG, format __VA_OPT__(, ) __VA_ARGS__)
 
#define LOG_USER(format, ...)   log_print(LOG_LEVEL_USER, format __VA_OPT__(, ) __VA_ARGS__)
 
#define LOG_INFO(format, ...)   log_print(LOG_LEVEL_INFO, format __VA_OPT__(, ) __VA_ARGS__)
 
#define LOG_WARN(format, ...)   log_print(LOG_LEVEL_WARN, format __VA_OPT__(, ) __VA_ARGS__)
 
#define LOG_ERR(format, ...)   log_print(LOG_LEVEL_ERR, format __VA_OPT__(, ) __VA_ARGS__)
 
#define LOG_PANIC(format, ...)   log_print(LOG_LEVEL_PANIC, format __VA_OPT__(, ) __VA_ARGS__)
 

Enumerations

enum  log_level_t {
  LOG_LEVEL_DEBUG , LOG_LEVEL_USER , LOG_LEVEL_INFO , LOG_LEVEL_WARN ,
  LOG_LEVEL_ERR , LOG_LEVEL_PANIC
}
 Log levels. More...
 

Functions

void log_init (void)
 Initialize the logging system.
 
void log_expose (void)
 Expose kernel logs via the /dev/klog file.
 
void log_nprint (log_level_t level, const char *string, uint64_t length)
 Print a unformatted log message.
 
void log_print (log_level_t level, const char *format,...)
 Print a formatted log message.
 
void log_vprint (log_level_t level, const char *format, va_list args)
 Print a formatted log message with a va_list.
 

Macro Definition Documentation

◆ LOG_MAX_BUFFER

#define LOG_MAX_BUFFER   0x1000

Maximum buffer size for various logging buffers.

Definition at line 25 of file log.h.

◆ LOG_DEBUG

#define LOG_DEBUG (   format,
  ... 
)    log_print(LOG_LEVEL_DEBUG, format __VA_OPT__(, ) __VA_ARGS__)

Definition at line 85 of file log.h.

◆ LOG_USER

#define LOG_USER (   format,
  ... 
)    log_print(LOG_LEVEL_USER, format __VA_OPT__(, ) __VA_ARGS__)

Definition at line 90 of file log.h.

◆ LOG_INFO

#define LOG_INFO (   format,
  ... 
)    log_print(LOG_LEVEL_INFO, format __VA_OPT__(, ) __VA_ARGS__)

Definition at line 91 of file log.h.

◆ LOG_WARN

#define LOG_WARN (   format,
  ... 
)    log_print(LOG_LEVEL_WARN, format __VA_OPT__(, ) __VA_ARGS__)

Definition at line 92 of file log.h.

◆ LOG_ERR

#define LOG_ERR (   format,
  ... 
)    log_print(LOG_LEVEL_ERR, format __VA_OPT__(, ) __VA_ARGS__)

Definition at line 93 of file log.h.

◆ LOG_PANIC

#define LOG_PANIC (   format,
  ... 
)    log_print(LOG_LEVEL_PANIC, format __VA_OPT__(, ) __VA_ARGS__)

Definition at line 94 of file log.h.

Enumeration Type Documentation

◆ log_level_t

Log levels.

Enumerator
LOG_LEVEL_DEBUG 
LOG_LEVEL_USER 
LOG_LEVEL_INFO 
LOG_LEVEL_WARN 
LOG_LEVEL_ERR 
LOG_LEVEL_PANIC 

Definition at line 30 of file log.h.

Function Documentation

◆ log_init()

void log_init ( void  )

Initialize the logging system.

Definition at line 93 of file log.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ log_expose()

void log_expose ( void  )

Expose kernel logs via the /dev/klog file.

Definition at line 112 of file log.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ log_nprint()

void log_nprint ( log_level_t  level,
const char *  string,
uint64_t  length 
)

Print a unformatted log message.

Warning
See log_vprint() regarding the log lock and LOG_LEVEL_PANIC.
Parameters
levelThe log level.
stringThe message string.
lengthThe length of the message.

Definition at line 194 of file log.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ log_print()

void log_print ( log_level_t  level,
const char *  format,
  ... 
)

Print a formatted log message.

Warning
See log_vprint() regarding the log lock and LOG_LEVEL_PANIC.
Parameters
levelThe log level.
formatThe format string.
...The format arguments.

Definition at line 212 of file log.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ log_vprint()

void log_vprint ( log_level_t  level,
const char *  format,
va_list  args 
)

Print a formatted log message with a va_list.

Warning
If the log level is LOG_LEVEL_PANIC, this function will not acquire the log lock to avoid recursive panics. Its up to the panic system to ensure all other CPUs are halted before calling this.
Parameters
levelThe log level.
formatThe format string.
argsThe va_list of arguments.

Definition at line 220 of file log.c.

Here is the call graph for this function:
Here is the caller graph for this function: