logger update
[vg.git] / vg.h
diff --git a/vg.h b/vg.h
index 2a52614b5fc2803c56c0e328edae5e88d580a507..35fb4fdee01b394db40be870a40b72138a7b01e9 100644 (file)
--- a/vg.h
+++ b/vg.h
 
   #include "vg_platform.h"
   #include "vg_mem.h"
-
-  #ifndef _WIN32
-    #include <execinfo.h>
-  #endif
-
-VG_STATIC void vg_print_backtrace(void)
-{
-#ifndef _WIN32
-
-   void *array[20];
-   char **strings;
-   int size, i;
-
-   size = backtrace( array, 20 );
-   strings = backtrace_symbols( array, size );
-
-   if( strings != NULL ){
-      vg_error( "---------------- gnu backtrace -------------\n" );
-
-      for( int i=0; i<size; i++ )
-         vg_info( "%s\n", strings[i] );
-
-      vg_error( "---------------- gnu backtrace -------------\n" );
-   }
-
-   free( strings );
-
-#endif
-}
   
   #ifdef VG_GAME
     #include "dep/glad/glad.h"
@@ -237,6 +208,14 @@ VG_STATIC enum vg_thread_purpose vg_thread_purpose(void)
    }
 }
 
+VG_STATIC void vg_assert_thread( enum vg_thread_purpose required ){
+   enum vg_thread_purpose purpose = vg_thread_purpose();
+
+   if( purpose != required ){
+      vg_fatal_error( "thread_purpose must be %u not %u\n", required, purpose );
+   }
+}
+
 VG_STATIC void _vg_opengl_sync_init(void)
 {
    vg.sem_loader = SDL_CreateSemaphore(1);
@@ -878,7 +857,7 @@ VG_STATIC void vg_fatal_error( const char *fmt, ... )
 {
    va_list args;
    va_start( args, fmt );
-   _vg_log_write( stderr, KRED "  fatal" KWHT "| " KRED, fmt, args );
+   _vg_logx_va( stderr, NULL, "fatal", KRED, fmt, args );
    va_end( args );
 
    vg_print_backtrace();
@@ -903,7 +882,7 @@ VG_STATIC void vg_fatal_error( const char *fmt, ... )
 {
    va_list args;
    va_start( args, fmt );
-   _vg_log_write( stderr, KRED "  fatal" KWHT "| " KRED, fmt, args );
+   _vg_logx_va( stderr, NULL, "fatal", KRED, fmt, args );
    va_end( args );
    exit(0);
 }
@@ -916,4 +895,6 @@ VG_STATIC void vg_fatal_error( const char *fmt, ... )
 u32 NvOptimusEnablement = 0x00000001;
 int AmdPowerXpressRequestHighPerformance = 1;
 
+#include "vg_log.c"
+
 #endif /* VG_HEADER_H */