Skip to content

Commit

Permalink
logger: allow suppressing boot logs
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Sep 9, 2024
1 parent 8cca328 commit d85b326
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/include/kernel/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <stdint.h>
#include <stdarg.h>
#include <stdbool.h>

#define KPRINTF_LEVEL_DEBUG 0
#define KPRINTF_LEVEL_WARNING 1
Expand All @@ -20,5 +21,5 @@
#define KERROR(...) kprintf(KPRINTF_LEVEL_ERROR, __FILE__+4, __VA_ARGS__)
#define KPANIC(...) kprintf(KPRINTF_LEVEL_PANIC, __FILE__+4, __VA_ARGS__)

void loggerSetVerbose(bool);
int kprintf(int, const char *, const char *, ...);
int vkprintf(int, const char *, const char *, va_list);
9 changes: 9 additions & 0 deletions src/logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,23 @@
* Core Microkernel
*/

#include <stdbool.h>
#include <stdio.h>
#include <kernel/logger.h>
#include <platform/lock.h>
#include <platform/platform.h>

static lock_t lock = LOCK_INITIAL;
static bool verbose = true;

void loggerSetVerbose(bool v) {
verbose = v;
}

int kprintf(int level, const char *src, const char *f, ...) {
if(!verbose && (level != KPRINTF_LEVEL_ERROR || level != KPRINTF_LEVEL_PANIC))
return 0;

acquireLockBlocking(&lock);

int len = printf("\e[37m%08d ", platformUptime());
Expand Down

0 comments on commit d85b326

Please sign in to comment.