mirror of
https://github.com/imgproxy/imgproxy.git
synced 2024-11-29 08:22:11 +02:00
35 lines
541 B
Go
35 lines
541 B
Go
package gliblog
|
|
|
|
/*
|
|
#cgo pkg-config: glib-2.0
|
|
#include "gliblog.h"
|
|
*/
|
|
import "C"
|
|
import log "github.com/sirupsen/logrus"
|
|
|
|
//export logGLib
|
|
func logGLib(cdomain *C.char, logLevel C.GLogLevelFlags, cstr *C.char) {
|
|
str := C.GoString(cstr)
|
|
|
|
var domain string
|
|
if cdomain != nil {
|
|
domain = C.GoString(cdomain)
|
|
}
|
|
if len(domain) == 0 {
|
|
domain = "GLib"
|
|
}
|
|
|
|
entry := log.WithField("source", domain)
|
|
|
|
switch logLevel {
|
|
case C.G_LOG_LEVEL_WARNING:
|
|
entry.Warn(str)
|
|
default:
|
|
entry.Error(str)
|
|
}
|
|
}
|
|
|
|
func Init() {
|
|
C.glib_log_configure()
|
|
}
|