PatchworkOS  da8a090
A non-POSIX operating system.
Loading...
Searching...
No Matches
Logging

Logging. More...

Collaboration diagram for Logging:

Detailed Description

Logging.

Modules

 Log file
 Userspace kernel log file.
 
 Screen
 Screen logging.
 
 Panic
 Panic handling.
 

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_output_t { LOG_OUTPUT_SERIAL = 1 << 0 , LOG_OUTPUT_SCREEN = 1 << 1 , LOG_OUTPUT_FILE = 1 << 2 }
 Logging output options. More...
 
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_screen_enable (void)
 Enable logging to the screen.
 
void log_screen_disable (void)
 Disable logging to the screen.
 
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 100 of file log.h.

◆ LOG_USER

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

Definition at line 105 of file log.h.

◆ LOG_INFO

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

Definition at line 106 of file log.h.

◆ LOG_WARN

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

Definition at line 107 of file log.h.

◆ LOG_ERR

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

Definition at line 108 of file log.h.

◆ LOG_PANIC

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

Definition at line 109 of file log.h.

Enumeration Type Documentation

◆ log_output_t

Logging output options.

Enumerator
LOG_OUTPUT_SERIAL 
LOG_OUTPUT_SCREEN 
LOG_OUTPUT_FILE 

Definition at line 30 of file log.h.

◆ 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 40 of file log.h.

Function Documentation

◆ log_init()

void log_init ( void  )

Initialize the logging system.

Definition at line 51 of file log.c.

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

◆ log_screen_enable()

void log_screen_enable ( void  )

Enable logging to the screen.

Definition at line 76 of file log.c.

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

◆ log_screen_disable()

void log_screen_disable ( void  )

Disable logging to the screen.

Definition at line 89 of file log.c.

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 168 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 191 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 199 of file log.c.

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