PatchworkOS
Loading...
Searching...
No Matches
log.c File Reference
#include <kernel/log/log.h>
#include <kernel/cpu/cpu.h>
#include <kernel/cpu/smp.h>
#include <kernel/drivers/com.h>
#include <kernel/log/log_file.h>
#include <kernel/log/log_screen.h>
#include <kernel/sched/timer.h>
#include <kernel/sync/lock.h>
#include <boot/boot_info.h>
#include <kernel/version.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/io.h>
#include <sys/proc.h>

Go to the source code of this file.

Functions

static void log_splash (void)
 
void log_init (const boot_gop_t *gop)
 Initialize the logging system.
 
void log_screen_enable ()
 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.
 
static void log_print_header (log_level_t level, const char *prefix)
 
static void log_handle_char (log_level_t level, const char *prefix, char chr)
 
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.
 

Variables

static lock_t lock = LOCK_CREATE
 
static char lineBuffer [LOG_MAX_BUFFER] = {0}
 
static char workingBuffer [LOG_MAX_BUFFER] = {0}
 
static log_output_t outputs = 0
 
static log_level_t minLevel = 0
 
static bool isLastCharNewline = 0
 
static bool firstHeaderPrinted = false
 
static const char * levelNames []
 

Function Documentation

◆ log_handle_char()

static void log_handle_char ( log_level_t  level,
const char *  prefix,
char  chr 
)
static

Definition at line 142 of file log.c.

References isLastCharNewline, log_print_header(), and log_write().

Referenced by log_vprint().

◆ log_print_header()

static void log_print_header ( log_level_t  level,
const char *  prefix 
)
static

◆ log_splash()

static void log_splash ( void  )
static

Definition at line 38 of file log.c.

References levelNames, LOG_INFO, LOG_OUTPUT_FILE, LOG_OUTPUT_SCREEN, LOG_OUTPUT_SERIAL, minLevel, and outputs.

Referenced by log_init().

Variable Documentation

◆ firstHeaderPrinted

bool firstHeaderPrinted = false
static

Definition at line 27 of file log.c.

Referenced by log_print_header().

◆ isLastCharNewline

bool isLastCharNewline = 0
static

Definition at line 26 of file log.c.

Referenced by log_handle_char(), and log_init().

◆ levelNames

const char* levelNames[]
static
Initial value:
= {
[LOG_LEVEL_DEBUG] = "D",
[LOG_LEVEL_USER] = "U",
[LOG_LEVEL_INFO] = "I",
[LOG_LEVEL_WARN] = "W",
[LOG_LEVEL_ERR] = "E",
[LOG_LEVEL_PANIC] = "P",
}
@ LOG_LEVEL_ERR
Definition log.h:44
@ LOG_LEVEL_DEBUG
Definition log.h:40
@ LOG_LEVEL_USER
Definition log.h:41
@ LOG_LEVEL_WARN
Definition log.h:43
@ LOG_LEVEL_PANIC
Definition log.h:45
@ LOG_LEVEL_INFO
Definition log.h:42

Definition at line 29 of file log.c.

Referenced by log_print_header(), and log_splash().

◆ lineBuffer

char lineBuffer[LOG_MAX_BUFFER] = {0}
static

Definition at line 22 of file log.c.

Referenced by config_open(), and log_vprint().

◆ lock

lock_t lock = LOCK_CREATE
static

Definition at line 20 of file log.c.

Referenced by log_screen_disable(), log_screen_enable(), and log_vprint().

◆ minLevel

log_level_t minLevel = 0
static

Definition at line 25 of file log.c.

Referenced by log_init(), log_splash(), and log_vprint().

◆ outputs

log_output_t outputs = 0
static

Definition at line 24 of file log.c.

Referenced by log_init(), log_screen_disable(), log_screen_enable(), log_splash(), and log_write().

◆ workingBuffer

char workingBuffer[LOG_MAX_BUFFER] = {0}
static

Definition at line 23 of file log.c.

Referenced by log_print_header().