PatchworkOS
Loading...
Searching...
No Matches
log.h File Reference
#include <boot/boot_info.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <sys/io.h>
#include <sys/math.h>
#include <sys/proc.h>

Go to the source code of this file.

Macros

#define LOG_MAX_BUFFER   0x1000
 Maximum buffer size for a single log line.
 
#define LOG_DEBUG(format, ...)   log_print(LOG_LEVEL_DEBUG, FILE_BASENAME, format __VA_OPT__(, ) __VA_ARGS__)
 
#define LOG_USER(format, ...)   log_print(LOG_LEVEL_USER, FILE_BASENAME, format __VA_OPT__(, ) __VA_ARGS__)
 
#define LOG_INFO(format, ...)   log_print(LOG_LEVEL_INFO, FILE_BASENAME, format __VA_OPT__(, ) __VA_ARGS__)
 
#define LOG_WARN(format, ...)   log_print(LOG_LEVEL_WARN, FILE_BASENAME, format __VA_OPT__(, ) __VA_ARGS__)
 
#define LOG_ERR(format, ...)   log_print(LOG_LEVEL_ERR, FILE_BASENAME, format __VA_OPT__(, ) __VA_ARGS__)
 
#define LOG_PANIC(format, ...)   log_print(LOG_LEVEL_PANIC, FILE_BASENAME, 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 (const boot_gop_t *gop)
 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_write (const char *string, uint64_t length)
 Write directly to the log outputs without any formatting or headers.
 
uint64_t log_print (log_level_t level, const char *prefix, const char *format,...)
 Print a formatted log message.
 
uint64_t log_vprint (log_level_t level, const char *prefix, const char *format, va_list args)
 Print a formatted log message with a va_list.