mirror of
https://github.com/status-im/status-go.git
synced 2025-01-22 04:31:30 +00:00
add file/stream log handlers to StatusNode (#833)
* add file/stream log handlers to StatusNode * move log initialisation to the lib pkg used by react * remove error check in log initialisation
This commit is contained in:
parent
19556554a6
commit
c32a82b88d
@ -32,15 +32,45 @@ func GenerateConfig(datadir *C.char, networkID C.int, devMode C.int) *C.char {
|
|||||||
return C.CString(string(outBytes))
|
return C.CString(string(outBytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func initLogger(config *params.NodeConfig) {
|
||||||
|
var (
|
||||||
|
handler log.Handler
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
if config.LogFile != "" {
|
||||||
|
handler, err = log.FileHandler(config.LogFile, log.LogfmtFormat())
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
handler = log.StreamHandler(os.Stderr, log.TerminalFormat(true))
|
||||||
|
}
|
||||||
|
|
||||||
|
// level, err := log.LvlFromString(strings.ToLower(config.LogLevel))
|
||||||
|
level, err := log.LvlFromString("trace")
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
filteredHandler := log.LvlFilterHandler(level, handler)
|
||||||
|
log.Root().SetHandler(filteredHandler)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
//StartNode - start Status node
|
//StartNode - start Status node
|
||||||
//export StartNode
|
//export StartNode
|
||||||
func StartNode(configJSON *C.char) *C.char {
|
func StartNode(configJSON *C.char) *C.char {
|
||||||
config, err := params.LoadNodeConfig(C.GoString(configJSON))
|
config, err := params.LoadNodeConfig(C.GoString(configJSON))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return makeJSONResponse(err)
|
return makeJSONResponse(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initLogger(config)
|
||||||
statusAPI.StartNodeAsync(config)
|
statusAPI.StartNodeAsync(config)
|
||||||
|
|
||||||
return makeJSONResponse(nil)
|
return makeJSONResponse(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user