File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,42 @@ Here you can check a small tutorial of how to use this component in an orders sc
3535
3636[ Tutorial] ( docs/how_to.md )
3737
38+ ## Logging
39+
40+ GoEngine uses default ` log ` package for debug logging. If you want to use your own logger - ` goengine.SetLogHandler() `
41+ is available. Here is how you can use, e.g. ` github.com/sirupsen/logrus ` for logging:
42+
43+ ``` go
44+ package main
45+
46+ import (
47+ " github.com/hellofresh/goengine"
48+ log " github.com/sirupsen/logrus"
49+ )
50+
51+ func main () {
52+ goengine.SetLogHandler (func (msg string , fields map [string ]interface {}, err error ) {
53+ if nil == fields && nil == err {
54+ log.Debug (msg)
55+ } else {
56+ var entry *log.Entry
57+ if fields != nil {
58+ entry = log.WithFields (log.Fields (fields))
59+ if nil != err {
60+ entry = entry.WithError (err)
61+ }
62+ } else {
63+ entry = log.WithError (err)
64+ }
65+
66+ entry.Debug (msg)
67+ }
68+ })
69+
70+ // do your application stuff
71+ }
72+ ```
73+
3874## Contributing
3975
4076Please see [ CONTRIBUTING] ( CONTRIBUTING.md ) for details.
You can’t perform that action at this time.
0 commit comments