Open Broadcaster Software
Free, open source software for live streaming and recording
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
base.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Hugh Bailey <obs.jim@gmail.com>
3  *
4  * Permission to use, copy, modify, and distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #pragma once
18 
19 #include <stdarg.h>
20 
21 #include "c99defs.h"
22 
23 /*
24  * Just contains logging/crash related stuff
25  */
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #define STRINGIFY(x) #x
32 #define STRINGIFY_(x) STRINGIFY(x)
33 #define S__LINE__ STRINGIFY_(__LINE__)
34 
35 #define INT_CUR_LINE __LINE__
36 #define FILE_LINE __FILE__ " (" S__LINE__ "): "
37 
38 enum {
46  LOG_ERROR = 100,
47 
55  LOG_WARNING = 200,
56 
60  LOG_INFO = 300,
61 
65  LOG_DEBUG = 400
66 };
67 
68 typedef void (*log_handler_t)(int lvl, const char *msg, va_list args, void *p);
69 
70 EXPORT void base_get_log_handler(log_handler_t *handler, void **param);
71 EXPORT void base_set_log_handler(log_handler_t handler, void *param);
72 
74  void (*handler)(const char *, va_list, void *),
75  void *param);
76 
77 EXPORT void blogva(int log_level, const char *format, va_list args);
78 
79 #ifndef _MSC_VER
80 #define PRINTFATTR(f, a) __attribute__((__format__(__printf__, f, a)))
81 #else
82 #define PRINTFATTR(f, a)
83 #endif
84 
85 PRINTFATTR(2, 3)
86 EXPORT void blog(int log_level, const char *format, ...);
87 PRINTFATTR(1, 2)
88 EXPORT void bcrash(const char *format, ...);
89 
90 #undef PRINTFATTR
91 
92 #ifdef __cplusplus
93 }
94 #endif
Definition: base.h:46
EXPORT void bcrash(const char *format,...)
EXPORT void blogva(int log_level, const char *format, va_list args)
EXPORT void blog(int log_level, const char *format,...)
Definition: base.h:60
EXPORT void base_get_log_handler(log_handler_t *handler, void **param)
#define EXPORT
Definition: c99defs.h:49
EXPORT void base_set_crash_handler(void(*handler)(const char *, va_list, void *), void *param)
EXPORT void base_set_log_handler(log_handler_t handler, void *param)
Definition: base.h:55
Definition: base.h:65
#define PRINTFATTR(f, a)
Definition: base.h:80
void(* log_handler_t)(int lvl, const char *msg, va_list args, void *p)
Definition: base.h:68