mirror of https://github.com/tailix/mrubyvisor.git
Move logging to separate module
This commit is contained in:
parent
85dab53e12
commit
7cb0b14893
|
@ -20,7 +20,7 @@ CPPFLAGS = \
|
|||
$(MRUBY_FLAGS) \
|
||||
-DKERNAUX_DEBUG \
|
||||
|
||||
OBJS = start.S.o main.c.o libc.c.o
|
||||
OBJS = start.S.o main.c.o libc.c.o logger.c.o
|
||||
|
||||
all: $(MRUBYVISOR)
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "libc.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -42,7 +43,7 @@ void my_abort()
|
|||
|
||||
void my_exit(const int status)
|
||||
{
|
||||
kernaux_drivers_console_printf("exit: %d\n", status);
|
||||
logger_exit(status);
|
||||
kernaux_drivers_shutdown_poweroff();
|
||||
|
||||
// TODO: libkernaux shutdown poweroff noreturn
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
#include "logger.h"
|
||||
|
||||
#include <kernaux/drivers/console.h>
|
||||
|
||||
void logger_assert(
|
||||
const char *const file,
|
||||
const int line,
|
||||
const char *const str
|
||||
) {
|
||||
kernaux_drivers_console_printf("panic: %s:%u: \"%s\"\n", file, line, str);
|
||||
}
|
||||
|
||||
void logger_exit(const int status)
|
||||
{
|
||||
kernaux_drivers_console_printf("exit: %d\n", status);
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
#ifndef INCLUDED_LOGGER
|
||||
#define INCLUDED_LOGGER
|
||||
|
||||
void logger_assert(const char *file, int line, const char *str);
|
||||
void logger_exit(int status);
|
||||
|
||||
#endif
|
|
@ -1,4 +1,5 @@
|
|||
#include "libc.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
@ -76,7 +77,7 @@ void main(
|
|||
|
||||
void assert(const char *const file, const int line, const char *const str)
|
||||
{
|
||||
kernaux_drivers_console_printf("panic: %s:%u: \"%s\"\n", file, line, str);
|
||||
logger_assert(file, line, str);
|
||||
kernaux_drivers_shutdown_poweroff();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue