clean logger function vg3
authorhgn <hgodden00@gmail.com>
Fri, 6 Sep 2024 03:29:38 +0000 (04:29 +0100)
committerhgn <hgodden00@gmail.com>
Fri, 6 Sep 2024 03:29:38 +0000 (04:29 +0100)
vg_console.c
vg_engine.c
vg_log.c
vg_log.h

index 00d8e5f3d4d38f0aa42f653e8180507e16983b3d..b1f320a6deafed034ea12dfb03593d10d8080338 100644 (file)
@@ -676,7 +676,6 @@ void vg_console_draw( ui_context *ctx )
    /* 
     * Input area 
     */
-
    struct ui_textbox_callbacks callbacks = 
    {
       .up = _vg_console_on_up,
index 2470b49423c28048184c79aeff268b363c7d8c1c..37293b0da3e89aeba8ec9c8a58078c2bd0abaf0c 100644 (file)
@@ -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<size; i++ )
-         vg_info( "%s\n", strings[i] );
+         vg_low( "%s\n", strings[i] );
    }
 
    free( strings );
index 2168444b22b01336012a1a9347f82eafa37f853c..cb168e6f38d12a76c3085f05c75fc162ccb61f33 100644 (file)
--- a/vg_log.c
+++ b/vg_log.c
@@ -24,65 +24,62 @@ void _vg_logx_va( FILE *file,
                          const char *colour,
                          const char *fmt, va_list args )
 {
-
-   /* @model.h:2000     info| dwahjdiawdjaiwdwadwa  djaidjwa\n
-    *                       | djwaidwaj      waodawh a\n
-    *                       | dwajdkiawjdiw 
-    */
-
 #ifdef VG_ENGINE
    SDL_AtomicLock( &vg_log.print_sl );
 #endif
 
-       char buffer[4096];
-
+       char buffer[4096], line[96];
    vsnprintf( buffer, VG_ARRAY_LEN(buffer), fmt, args );
 
-   const char *line = buffer;
-   char logline[96];
+   int line_length = snprintf( line, 90, "%s%7s" KNRM "|%s ", 
+                               colour, prefix, colour );
 
-   for( u32 i=0; i<VG_ARRAY_LEN(buffer); i++ ){
+   for( u32 i=0; i<VG_ARRAY_LEN(buffer); i ++ )
+   {
       char c = buffer[i];
+      char marker = '|';
+      bool flush = 0;
 
-      if( c == '\0' || c == '\n' ){
-         buffer[i] = '\0';
+      line[ line_length ++ ] = c;
 
-         const char *line_prefix = "",
-                    *line_location = "";
-
-         if( line == buffer ) {
-            line_prefix = prefix;
-            line_location = location;
-         }
+      if( line_length >= 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
index 89b86dc186e1976ba6e6e64877811adaae5b4191..ebfa59d6bc30938207194d1a6c22ca9b45deb500 100644 (file)
--- 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( ... ) \