allow other channel for non-dsp sounds (2D oneshots)
[vg.git] / vg_log.h
1 #pragma once
2
3 #include "vg_platform.h"
4 #include <stdio.h>
5
6 #define VG_LOG_MCSTR(S) VG_LOG_MCSTR2(S)
7 #define VG_LOG_MCSTR2(S) #S
8 #define VG_LOG_WHERE "@" __FILE__ ":" VG_LOG_MCSTR(__LINE__)\
9 " "
10
11 #define vg_success( ... ) \
12 vg_logx(stdout,VG_LOG_WHERE,"success",KGRN,__VA_ARGS__)
13 #define vg_info( ... ) \
14 vg_logx(stdout,VG_LOG_WHERE,"info",KNRM,__VA_ARGS__)
15 #define vg_warn( ... ) \
16 vg_logx(stdout,VG_LOG_WHERE,"warn",KYEL,__VA_ARGS__ )
17 #define vg_error( ... ) \
18 vg_logx(stdout,VG_LOG_WHERE,"error",KRED,__VA_ARGS__)
19 #define vg_low( ... ) \
20 vg_logx(stdout,VG_LOG_WHERE,"log",KWHT,__VA_ARGS__)
21
22 #define KNRM "\x1B[0m"
23 #define KBLK "\x1B[30m"
24 #define KRED "\x1B[31m"
25 #define KGRN "\x1B[32m"
26 #define KYEL "\x1B[33m"
27 #define KBLU "\x1B[34m"
28 #define KMAG "\x1B[35m"
29 #define KCYN "\x1B[36m"
30 #define KWHT "\x1B[37m"
31
32 #define PRINTF_v2f( V2 ) "%.4f %.4f\n", V2[0], V2[1]
33 #define PRINTF_v3f( V3 ) "%.4f %.4f %.4f\n", V3[0], V3[1], V3[2]
34 #define PRINTF_v4f( V4 ) "%.4f %.4f %.4f %.4f\n", V4[0], V4[1], V4[2], V4[3]
35
36 #ifdef _WIN32
37 #define PRINTF_U64 "%llu"
38 #else
39 #define PRINTF_U64 "%lu"
40 #endif
41
42 #ifdef VG_ENGINE
43 #include "dep/sdl/include/SDL.h"
44 #endif
45
46 struct vg_log
47 {
48 char log[64][96];
49 u32 log_line_count, log_line_current;
50
51 #ifdef VG_ENGINE
52 SDL_SpinLock print_sl;
53 #endif
54 }
55 extern vg_log;
56
57 void vg_logx( FILE *file,
58 const char *location, const char *prefix,
59 const char *colour,
60 const char *fmt, ... );
61
62 void _vg_logx_va( FILE *file,
63 const char *location, const char *prefix,
64 const char *colour,
65 const char *fmt, va_list args );
66
67 void vg_print_backtrace(void);
68