PatchworkOS  19e446b
A non-POSIX operating system.
Loading...
Searching...
No Matches
log.c File Reference
#include <kernel/fs/devfs.h>
#include <kernel/fs/file.h>
#include <kernel/log/log.h>
#include <kernel/cpu/cpu.h>
#include <kernel/drivers/com.h>
#include <kernel/init/boot_info.h>
#include <kernel/log/screen.h>
#include <kernel/sched/clock.h>
#include <kernel/sched/timer.h>
#include <kernel/sched/wait.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 <string.h>
#include <sys/fs.h>
#include <sys/math.h>
#include <sys/proc.h>
Include dependency graph for log.c:

Go to the source code of this file.

Functions

static size_t klog_read (file_t *file, void *buffer, size_t count, size_t *offset)
 
static size_t klog_write (file_t *file, const void *buffer, size_t count, size_t *offset)
 
static void log_splash (void)
 
void log_init (void)
 Initialize the logging system.
 
void log_expose (void)
 Expose kernel logs via the /dev/klog file.
 
static void log_write (const char *string, uint64_t length)
 
static void log_print_header (log_level_t level)
 
static void log_handle_char (log_level_t level, char chr)
 
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.
 

Variables

static lock_t lock = LOCK_CREATE()
 
static char klogBuffer [CONFIG_KLOG_SIZE]
 
static uint64_t klogHead = 0
 
static dentry_tklog = NULL
 
static char lineBuffer [LOG_MAX_BUFFER] = {0}
 
static char workingBuffer [LOG_MAX_BUFFER] = {0}
 
static bool isLastCharNewline = false
 
static bool firstHeaderPrinted = false
 
static const char * levelNames []
 
static file_ops_t klogOps
 

Function Documentation

◆ klog_read()

static size_t klog_read ( file_t file,
void *  buffer,
size_t  count,
size_t offset 
)
static

Definition at line 45 of file log.c.

◆ klog_write()

static size_t klog_write ( file_t file,
const void *  buffer,
size_t  count,
size_t offset 
)
static

Definition at line 69 of file log.c.

Here is the call graph for this function:

◆ log_splash()

static void log_splash ( void  )
static

Definition at line 83 of file log.c.

Here is the caller graph for this function:

◆ log_write()

static void log_write ( const char *  string,
uint64_t  length 
)
static

Definition at line 128 of file log.c.

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

◆ log_print_header()

static void log_print_header ( log_level_t  level)
static

Definition at line 145 of file log.c.

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

◆ log_handle_char()

static void log_handle_char ( log_level_t  level,
char  chr 
)
static

Definition at line 172 of file log.c.

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

Variable Documentation

◆ lock

lock_t lock = LOCK_CREATE()
static

Definition at line 25 of file log.c.

◆ klogBuffer

char klogBuffer[CONFIG_KLOG_SIZE]
static

Definition at line 27 of file log.c.

◆ klogHead

uint64_t klogHead = 0
static

Definition at line 28 of file log.c.

◆ klog

dentry_t* klog = NULL
static

Definition at line 29 of file log.c.

◆ lineBuffer

char lineBuffer[LOG_MAX_BUFFER] = {0}
static

Definition at line 31 of file log.c.

◆ workingBuffer

char workingBuffer[LOG_MAX_BUFFER] = {0}
static

Definition at line 32 of file log.c.

◆ isLastCharNewline

bool isLastCharNewline = false
static

Definition at line 33 of file log.c.

◆ firstHeaderPrinted

bool firstHeaderPrinted = false
static

Definition at line 34 of file log.c.

◆ 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:36
@ LOG_LEVEL_DEBUG
Definition log.h:32
@ LOG_LEVEL_USER
Definition log.h:33
@ LOG_LEVEL_WARN
Definition log.h:35
@ LOG_LEVEL_PANIC
Definition log.h:37
@ LOG_LEVEL_INFO
Definition log.h:34

Definition at line 36 of file log.c.

◆ klogOps

file_ops_t klogOps
static
Initial value:
= {
.read = klog_read,
.write = klog_write,
}
static size_t klog_write(file_t *file, const void *buffer, size_t count, size_t *offset)
Definition log.c:69
static size_t klog_read(file_t *file, void *buffer, size_t count, size_t *offset)
Definition log.c:45

Definition at line 78 of file log.c.