improve logging from scripts
This commit is contained in:
parent
3313c800a9
commit
4587ba7266
7 changed files with 99 additions and 60 deletions
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
|
|
@ -18,6 +19,15 @@ static pxl8_log* g_log = NULL;
|
|||
void pxl8_log_init(pxl8_log* log) {
|
||||
g_log = log;
|
||||
g_log->level = PXL8_LOG_LEVEL_DEBUG;
|
||||
|
||||
const char* env_level = getenv("PXL8_LOG_LEVEL");
|
||||
if (env_level) {
|
||||
if (strcmp(env_level, "trace") == 0) g_log->level = PXL8_LOG_LEVEL_TRACE;
|
||||
else if (strcmp(env_level, "debug") == 0) g_log->level = PXL8_LOG_LEVEL_DEBUG;
|
||||
else if (strcmp(env_level, "info") == 0) g_log->level = PXL8_LOG_LEVEL_INFO;
|
||||
else if (strcmp(env_level, "warn") == 0) g_log->level = PXL8_LOG_LEVEL_WARN;
|
||||
else if (strcmp(env_level, "error") == 0) g_log->level = PXL8_LOG_LEVEL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
void pxl8_log_set_level(pxl8_log_level level) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue