X-Git-Url: https://harrygodden.com/git/?p=vg.git;a=blobdiff_plain;f=vg_log.c;fp=vg_log.c;h=84807daeaca72e1ee0f96b7d7ae3361ad86173e9;hp=638d63feaa13172d3df2e7cde302c38f34a77d2d;hb=3b14f3dcd5bf9dd3c85144f2123d667bfa4bb63f;hpb=fce86711735b15bff37de0f70716808410fcf269 diff --git a/vg_log.c b/vg_log.c index 638d63f..84807da 100644 --- a/vg_log.c +++ b/vg_log.c @@ -1,16 +1,18 @@ -#ifndef VG_LOG_C #include #include #include -#include "vg_stdint.h" #include "vg_platform.h" #include "vg_log.h" +#include "vg_string.h" #ifndef _WIN32 #include #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