-
Notifications
You must be signed in to change notification settings - Fork 22
/
log.go
64 lines (57 loc) · 1.47 KB
/
log.go
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
63
64
package wlroots
/*
* This an unstable interface of wlroots. No guarantees are made regarding the
* future consistency of this API.
*/
// #cgo pkg-config: wlroots wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #cgo pkg-config: wlroots wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #include <stdlib.h>
// #include <stdio.h>
// #include <wlr/util/log.h>
//
//
// void _wlr_log_cb(enum wlr_log_importance importance, char *msg);
//
//
// static inline void _wlr_log_inner_cb(enum wlr_log_importance importance, const char *fmt, va_list args) {
// char *msg = NULL;
// if (vasprintf(&msg, fmt, args) == -1) {
// return;
// }
//
// _wlr_log_cb(importance, msg);
// free(msg);
// }
//
//
// static inline void _wlr_log_set_cb(enum wlr_log_importance verbosity, bool is_set) {
// wlr_log_init(verbosity, is_set ? &_wlr_log_inner_cb : NULL);
// }
//
//
import "C"
type (
LogImportance uint32
LogFunc func(importance LogImportance, msg string)
)
const (
LogImportanceSilent LogImportance = C.WLR_SILENT
LogImportanceError LogImportance = C.WLR_ERROR
LogImportanceInfo LogImportance = C.WLR_INFO
LogImportanceDebug LogImportance = C.WLR_DEBUG
)
var (
onLog LogFunc
)
//export _wlr_log_cb
func _wlr_log_cb(importance LogImportance, msg *C.char) {
if onLog != nil {
onLog(importance, C.GoString(msg))
}
}
func OnLog(verbosity LogImportance, cb LogFunc) {
C._wlr_log_set_cb(C.enum_wlr_log_importance(verbosity), cb != nil)
onLog = cb
}