X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=vg_log.c;fp=vg_log.c;h=638d63feaa13172d3df2e7cde302c38f34a77d2d;hb=dd402a7717847a2d74c3b98e3f3970cde4874a73;hp=0000000000000000000000000000000000000000;hpb=48149581c10efff916dfad10f014b90837d531ea;p=vg.git diff --git a/vg_log.c b/vg_log.c new file mode 100644 index 0000000..638d63f --- /dev/null +++ b/vg_log.c @@ -0,0 +1,136 @@ +#ifndef VG_LOG_C +#include +#include +#include +#include "vg_stdint.h" +#include "vg_platform.h" +#include "vg_log.h" + +#ifndef _WIN32 + #include +#endif + +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 ++; + + char *dest = vg_log.log[ vg_log.log_line_current ++ ]; + vg_strncpy( str, dest, vg_list_size(vg_log.log[0]), k_strncpy_allow_cutoff ); + + if( vg_log.log_line_current >= vg_list_size( vg_log.log ) ) + vg_log.log_line_current = 0; +} + +static void _vg_logx_va( FILE *file, + const char *location, const char *prefix, + const char *colour, + const char *fmt, va_list args ) +{ + + /* @model.h:2000 info| dwahjdiawdjaiwdwadwa djaidjwa\n + * | djwaidwaj waodawh a\n + * | dwajdkiawjdiw + */ + +#ifdef VG_GAME + SDL_AtomicLock( &log_print_sl ); +#endif + + char buffer[4096]; + + vsnprintf( buffer, vg_list_size(buffer), fmt, args ); + + const char *line = buffer; + char logline[96]; + + for( u32 i=0; i