build system revision
[vg.git] / vg_log.c
index 638d63feaa13172d3df2e7cde302c38f34a77d2d..84807daeaca72e1ee0f96b7d7ae3361ad86173e9 100644 (file)
--- a/vg_log.c
+++ b/vg_log.c
@@ -1,16 +1,18 @@
-#ifndef VG_LOG_C
 #include <stdarg.h>
 #include <string.h>
 #include <malloc.h>
-#include "vg_stdint.h"
 #include "vg_platform.h"
 #include "vg_log.h"
+#include "vg_string.h"
 
 #ifndef _WIN32
  #include <execinfo.h>
 #endif
 
-static void _vg_log_append_line( const char *str ){
+struct vg_log vg_log;
+
+static void _vg_log_append_line( const char *str )
+{
    if( vg_log.log_line_count < vg_list_size( vg_log.log ) )
       vg_log.log_line_count ++;
 
@@ -21,7 +23,7 @@ static void _vg_log_append_line( const char *str ){
       vg_log.log_line_current = 0;
 }
 
-static void _vg_logx_va( FILE *file, 
+void _vg_logx_va( FILE *file, 
                          const char *location, const char *prefix,
                          const char *colour,
                          const char *fmt, va_list args )
@@ -32,8 +34,8 @@ static void _vg_logx_va( FILE *file,
     *                       | dwajdkiawjdiw 
     */
 
-#ifdef VG_GAME
-   SDL_AtomicLock( &log_print_sl );
+#ifdef VG_ENGINE
+   SDL_AtomicLock( &vg_log.print_sl );
 #endif
 
        char buffer[4096];
@@ -62,7 +64,7 @@ static void _vg_logx_va( FILE *file,
          _vg_log_append_line( logline );
 
          if( location ){
-#ifdef VG_GAME
+#ifdef VG_ENGINE
             const char *thread_colours[] = {
                KGRN, KMAG, KCYN, KYEL, KBLU
             };
@@ -87,15 +89,16 @@ static void _vg_logx_va( FILE *file,
       }
    }
 
-#ifdef VG_GAME
-   SDL_AtomicUnlock( &log_print_sl );
+#ifdef VG_ENGINE
+   SDL_AtomicUnlock( &vg_log.print_sl );
 #endif
 }
 
-static void vg_logx( FILE *file, 
-                     const char *location, const char *prefix, 
-                     const char *colour,
-                     const char *fmt, ... ){
+void vg_logx( FILE *file, 
+             const char *location, const char *prefix, 
+             const char *colour,
+             const char *fmt, ... )
+{
 
    va_list args;
    va_start( args, fmt );
@@ -109,9 +112,9 @@ static void vg_logx( FILE *file,
    va_end( args );
 }
 
-static void vg_print_backtrace(void){
+void vg_print_backtrace(void)
+{
 #ifndef _WIN32
-
    void *array[20];
    char **strings;
    int size, i;
@@ -119,7 +122,8 @@ static void vg_print_backtrace(void){
    size = backtrace( array, 20 );
    strings = backtrace_symbols( array, size );
 
-   if( strings != NULL ){
+   if( strings != NULL )
+   {
       vg_error( "---------------- gnu backtrace -------------\n" );
 
       for( int i=0; i<size; i++ )
@@ -132,5 +136,3 @@ static void vg_print_backtrace(void){
 
 #endif
 }
-
-#endif /* VG_LOG_C */