fusee: Improve integration with the new logging system

fusee: Implement log level configuration from BCT.ini
This commit is contained in:
hexkyz
2018-09-28 21:12:59 +01:00
parent 2e6983d214
commit ca0e41e8a0
16 changed files with 98 additions and 139 deletions

View File

@@ -20,17 +20,21 @@
#include "vsprintf.h"
/* default log level for screen output */
ScreenLogLevel g_screen_log_level = SCREEN_LOG_LEVEL_MANDATORY;
ScreenLogLevel g_screen_log_level = SCREEN_LOG_LEVEL_NONE;
void log_set_log_level(ScreenLogLevel log_level) {
g_screen_log_level = log_level;
}
ScreenLogLevel log_get_log_level() {
return g_screen_log_level;
}
void log_to_uart(const char *message) {
/* TODO: add UART logging */
}
void print_to_screen(ScreenLogLevel screen_log_level, char *message) {
static void print_to_screen(ScreenLogLevel screen_log_level, char *message) {
/* don't print to screen if below log level */
if(screen_log_level > g_screen_log_level) return;
@@ -58,7 +62,7 @@ void vprint(ScreenLogLevel screen_log_level, const char *fmt, va_list args)
print_to_screen(screen_log_level, buf);
}
void add_prefix(ScreenLogLevel screen_log_level, const char *fmt, char *buf) {
static void add_prefix(ScreenLogLevel screen_log_level, const char *fmt, char *buf) {
char typebuf[] = "[%s] %s";
/* apply prefix and append message format */

View File

@@ -14,8 +14,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FUSEE_PRIMARY_PRINT_H
#define FUSEE_PRIMARY_PRINT_H
#ifndef FUSEE_LOG_H
#define FUSEE_LOG_H
#define PRINT_MESSAGE_MAX_LENGTH 512
@@ -32,10 +32,10 @@ typedef enum {
SCREEN_LOG_LEVEL_NO_PREFIX = 0x100 /* OR this to your LOG_LEVEL to prevent prefix creation */
} ScreenLogLevel;
/* TODO: make this configurable by BCT.ini */
extern ScreenLogLevel g_screen_log_level;
void log_set_log_level(ScreenLogLevel screen_log_level);
ScreenLogLevel log_get_log_level();
void log_to_uart(const char *message);
void vprint(ScreenLogLevel screen_log_level, const char *fmt, va_list args);
void print(ScreenLogLevel screen_log_level, const char* fmt, ...);