changes to fit the codestyle

improved a comment
removed unused code and imports
This commit is contained in:
Resaec 2018-09-24 00:02:58 +02:00
parent 8cc266174d
commit 1eb3d7969e
No known key found for this signature in database
GPG Key ID: 5E890BD898EA9064
3 changed files with 16 additions and 19 deletions

View File

@ -20,7 +20,4 @@
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
//#define vprint vprintf
//#define print printf
#endif #endif

View File

@ -30,21 +30,22 @@ void log_to_uart(const char *message) {
/* TODO: add UART logging */ /* TODO: add UART logging */
} }
void print_to_screen(ScreenLogLevel screenLogLevel, char *message) { void print_to_screen(ScreenLogLevel screen_log_level, char *message) {
/* don't print to screen if below log level */ /* don't print to screen if below log level */
if(g_screen_log_level == SCREEN_LOG_LEVEL_NONE || screenLogLevel > g_screen_log_level) return; if(screen_log_level > g_screen_log_level) return;
//video_puts(buf); //video_puts(buf);
printf(message); printf(message);
} }
/** /**
* vprintk - logs a message to the console * vprintk - logs a message and prints it to screen based on its screen_log_level
* *
* This text will not be colored or prefixed but logged to UART * If the level is below g_screen_log_level it will not be shown but logged to UART
* This text will not be colored or prefixed
* UART is TODO * UART is TODO
*/ */
void vprint(ScreenLogLevel screenLogLevel, const char *fmt, va_list args) void vprint(ScreenLogLevel screen_log_level, const char *fmt, va_list args)
{ {
char buf[PRINT_MESSAGE_MAX_LENGTH]; char buf[PRINT_MESSAGE_MAX_LENGTH];
vsnprintf(buf, PRINT_MESSAGE_MAX_LENGTH, fmt, args); vsnprintf(buf, PRINT_MESSAGE_MAX_LENGTH, fmt, args);
@ -52,16 +53,16 @@ void vprint(ScreenLogLevel screenLogLevel, const char *fmt, va_list args)
/* log to UART */ /* log to UART */
log_to_uart(buf); log_to_uart(buf);
print_to_screen(screenLogLevel, buf); print_to_screen(screen_log_level, buf);
} }
/** /**
* print - logs a message and prints it to screen based on its screenLogLevel * print - logs a message and prints it to screen based on its screen_log_level
* *
* If the level is below g_screen_log_level it will not be shown but logged to UART * If the level is below g_screen_log_level it will not be shown but logged to UART
* UART is TODO * UART is TODO
*/ */
void print(ScreenLogLevel screenLogLevel, const char * fmt, ...) void print(ScreenLogLevel screen_log_level, const char * fmt, ...)
{ {
char typebuf[] = "[%s] %s"; char typebuf[] = "[%s] %s";
char buf[PRINT_MESSAGE_MAX_LENGTH] = {}; char buf[PRINT_MESSAGE_MAX_LENGTH] = {};
@ -70,7 +71,7 @@ void print(ScreenLogLevel screenLogLevel, const char * fmt, ...)
/* apply prefix and append message format */ /* apply prefix and append message format */
/* TODO: add coloring to the output */ /* TODO: add coloring to the output */
/* TODO: make splash disappear if level > MANDATORY */ /* TODO: make splash disappear if level > MANDATORY */
switch(screenLogLevel) switch(screen_log_level)
{ {
case SCREEN_LOG_LEVEL_ERROR: case SCREEN_LOG_LEVEL_ERROR:
snprintf(buf, PRINT_MESSAGE_MAX_LENGTH, typebuf, "ERROR", fmt); snprintf(buf, PRINT_MESSAGE_MAX_LENGTH, typebuf, "ERROR", fmt);
@ -100,5 +101,5 @@ void print(ScreenLogLevel screenLogLevel, const char * fmt, ...)
/* log to UART */ /* log to UART */
log_to_uart(message); log_to_uart(message);
print_to_screen(screenLogLevel, message); print_to_screen(screen_log_level, message);
} }

View File

@ -19,8 +19,7 @@
#define PRINT_MESSAGE_MAX_LENGTH 512 #define PRINT_MESSAGE_MAX_LENGTH 512
//#include <stdint.h> #include <stdarg.h>
#include "../../fusee-primary/src/lib/vsprintf.h"
typedef enum { typedef enum {
SCREEN_LOG_LEVEL_NONE = 0, SCREEN_LOG_LEVEL_NONE = 0,
@ -36,7 +35,7 @@ extern ScreenLogLevel g_screen_log_level;
void log_set_log_level(ScreenLogLevel screen_log_level); void log_set_log_level(ScreenLogLevel screen_log_level);
void log_to_uart(const char *message); void log_to_uart(const char *message);
void vprint(ScreenLogLevel screenLogLevel, const char *fmt, va_list args); void vprint(ScreenLogLevel screen_log_level, const char *fmt, va_list args);
void print(ScreenLogLevel screenLogLevel, const char* fmt, ...); void print(ScreenLogLevel screen_log_level, const char* fmt, ...);
#endif #endif