-
Notifications
You must be signed in to change notification settings - Fork 0
/
evel_logging.go
64 lines (52 loc) · 1.89 KB
/
evel_logging.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
package evel
/*
#cgo CFLAGS: -I/opt/evel-library/code/evel_library
#cgo LDFLAGS: -lcurl -L/opt/evel-library/output/x86_64
#include <evel.h>
#include <stdlib.h>
#
// A wrapper for the log_debug function due to the fact that
// Go does not support calling variadic C functions
static void cgo_evel_log(EVEL_LOG_LEVELS level, char * format)
{
log_debug(level, format);
}
*/
import "C"
import (
"unsafe"
"fmt"
)
/*******************************************************************************
* A wrapper to EVEL_ERROR macro
*
* @param format string fmt.Sprintf fromat
* @param i interface parameters that should be part of formatted message
*******************************************************************************/
func EvelError(format string, i ...interface{}) {
cStr := C.CString("ERROR: " + fmt.Sprintf(format, i...))
defer C.free(unsafe.Pointer(cStr))
C.cgo_evel_log(C.EVEL_LOG_ERROR, cStr)
}
/*******************************************************************************
* A wrapper to EVEL_INFO macro
*
* @param format string fmt.Sprintf fromat
* @param i interface parameters that should be part of formatted message
*******************************************************************************/
func EvelInfo(format string, i ...interface{}) {
cStr := C.CString(fmt.Sprintf(format, i...))
defer C.free(unsafe.Pointer(cStr))
C.cgo_evel_log(C.EVEL_LOG_INFO, cStr)
}
/*******************************************************************************
* A wrapper to EVEL_DEBUG macro
*
* @param format string fmt.Sprintf fromat
* @param i interface parameters that should be part of formatted message
*******************************************************************************/
func EvelDebug(format string, i ...interface{}) {
cStr := C.CString(fmt.Sprintf(format, i...))
defer C.free(unsafe.Pointer(cStr))
C.cgo_evel_log(C.EVEL_LOG_DEBUG, cStr)
}