Repository navigation
Expand file tree
/
Copy pathdebug_log.c
More file actions
62 lines (50 loc) · 1.53 KB
/
Copy pathdebug_log.c
File metadata and controls
62 lines (50 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* @file debug_log.c
* @author Ethan Gibson (ethan@gibsondevlab.com)
* @date 2019-02-18
*
* @brief Simple printf wrapper
*
* A printf wrapper that expands the functionality to color code terminal output and adds on-the-fly enable/disable
* of logs.
*
* @copyright Copyright Gibson Dev Lab(c) 2019
*/
#include "debug_log.h"
//======================================================================
// Dependencies
//======================================================================
// Standard C Libraries
#include <stdio.h>
#include <stdarg.h>
//======================================================================
// Public Types
//======================================================================
void _logRaw( const char *format, va_list args )
{
vprintf( format, args );
}
void debug_log_base( debug_log_cfg_t *cfg, debug_log_level_t logLevel, char *colorCode, char *logID, const char *file, const char* function, int line, const char *format, ... )
{
if( cfg->genLogLevel >= logLevel )
{
va_list args;
va_start( args, format );
printf( "%s%s %s : %s (%d)- ", colorCode, logID, file, function, line);
_logRaw( format, args );
printf( ANSI_COLOR_RESET "\n" );
fflush( stdout );
va_end( args );
}
}
void debug_log_raw( debug_log_cfg_t *cfg, const char *format, ... )
{
if( cfg-> logRaw )
{
va_list args;
va_start( args, format );
vprintf( format, args );
fflush( stdout );
va_end( args );
}
}