-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathos_log.h
52 lines (41 loc) · 1020 Bytes
/
os_log.h
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
#ifndef OSL_INCLUDE_OS_LOG_H
#define OSL_INCLUDE_OS_LOG_H
#include <stdarg.h>
#include <stdio.h>
#ifndef OSLDEF
#ifdef OSL_STATIC
#define OSLDEF static
#else
#define OSLDEF extern
#endif
#endif
typedef enum
{
OSL_DEBUG,
OSL_INFO,
OSL_WARNING,
OSL_ERROR,
OSL_NUM_LOG_TYPES
} osl_log_type_t;
static const char *log_type_to_cstr[OSL_NUM_LOG_TYPES]
= {[OSL_DEBUG] = "[DEBUG]",
[OSL_INFO] = "[INFO]",
[OSL_WARNING] = "[WARNING]",
[OSL_ERROR] = "[ERROR]"};
OSLDEF void osl_log(osl_log_type_t log_type, const char *msg);
OSLDEF void osl_logf(osl_log_type_t log_type, const char *format, ...);
#endif
#ifdef OS_LOG_IMPLEMENTATION
OSLDEF void osl_log(osl_log_type_t log_type, const char *msg)
{
printf("%s %s\n", log_type_to_cstr[log_type], msg);
}
OSLDEF void osl_logf(osl_log_type_t log_type, const char *format, ...)
{
va_list args;
va_start(args, format);
printf("%s ", log_type_to_cstr[log_type]);
vprintf(format, args);
printf("\n");
}
#endif