From d0f65909290fd4981f2d0b6ad3389daf88777ac5 Mon Sep 17 00:00:00 2001 From: hgn Date: Fri, 6 Sep 2024 04:29:38 +0100 Subject: [PATCH] clean logger function --- vg_console.c | 1 - vg_engine.c | 6 ++--- vg_log.c | 73 +++++++++++++++++++++++++--------------------------- vg_log.h | 2 +- 4 files changed, 39 insertions(+), 43 deletions(-) diff --git a/vg_console.c b/vg_console.c index 00d8e5f..b1f320a 100644 --- a/vg_console.c +++ b/vg_console.c @@ -676,7 +676,6 @@ void vg_console_draw( ui_context *ctx ) /* * Input area */ - struct ui_textbox_callbacks callbacks = { .up = _vg_console_on_up, diff --git a/vg_engine.c b/vg_engine.c index 2470b49..37293b0 100644 --- a/vg_engine.c +++ b/vg_engine.c @@ -439,7 +439,7 @@ static void _vg_crashscreen(void) glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA); glBlendEquation(GL_FUNC_ADD); - glClearColor( 0.15f + sinf(vg.time_real)*0.1f, 0.0f, 0.0f,1.0f ); + glClearColor( 0.15f,0.0f,0.0f,1.0f ); glClear( GL_COLOR_BUFFER_BIT ); glViewport( 0,0, vg.window_x, vg.window_y ); @@ -786,10 +786,10 @@ void vg_fatal_exit(void) if( strings != NULL ) { - vg_info( "\n\n---------------- gnu backtrace -------------\n" ); + vg_error( "\n---------------- gnu backtrace -------------\n" ); for( int i=0; i= 90 ) + { + line[ line_length ++ ] = '\n'; + line[ line_length ] = '\0'; + flush = 1; + marker = '.'; + } - snprintf( logline, 96, "%s%7s" KNRM "|%s %s", - colour, line_prefix, colour, line ); - _vg_log_append_line( logline ); + if( c == '\n' ) + { + line[ line_length ] = '\0'; + flush = 1; + } - if( location ){ + if( flush || c == '\0' ) + { + if( location ) + { #ifdef VG_ENGINE - const char *thread_colours[] = { - KGRN, KMAG, KCYN, KYEL, KBLU - }; - + const char *thread_colours[] = { KGRN, KMAG, KCYN, KYEL, KBLU }; const char *colour = thread_colours[ (vg_thread_purpose() % VG_ARRAY_LEN( thread_colours ))]; - fprintf( file, "%s[%u]"KNRM"%.32s", - colour, vg_thread_purpose(), line_location ); + fprintf( file, "%s%u|"KNRM"%.32s", + colour, vg_thread_purpose(), location ); #else - fprintf( file, KNRM "%.32s", line_location ); + fprintf( file, KNRM "%.32s", location ); #endif } - fputs( logline, file ); - fputc( '\n', file ); - fputs( KNRM, file ); - - if( c == '\0' ) break; - if( buffer[i+1] == '\0' ) break; - line = buffer+i+1; + _vg_log_append_line( line ); + fputs( line, file ); + line_length = snprintf( line, 90, "%s " KNRM "%c%s ", + colour, marker, colour ); } + + if( c == '\0' ) break; + if( buffer[i+1] == '\0' ) break; } #ifdef VG_ENGINE diff --git a/vg_log.h b/vg_log.h index 89b86dc..ebfa59d 100644 --- a/vg_log.h +++ b/vg_log.h @@ -5,7 +5,7 @@ #define VG_LOG_MCSTR(S) VG_LOG_MCSTR2(S) #define VG_LOG_MCSTR2(S) #S -#define VG_LOG_WHERE "@" __FILE__ ":" VG_LOG_MCSTR(__LINE__)\ +#define VG_LOG_WHERE __FILE__ ":" VG_LOG_MCSTR(__LINE__)\ " " #define vg_success( ... ) \ -- 2.25.1