forked from TrueCloudLab/neoneo-go
95cbddf19e
``` anna@kiwi:~/Documents/GitProjects/nspcc-dev/neo-go$ ./bin/neo-go vm -p _ ____________ __________ _ ____ ___ / | / / ____/ __ \ / ____/ __ \ | | / / |/ / / |/ / __/ / / / /_____/ / __/ / / /____| | / / /|_/ / / /| / /___/ /_/ /_____/ /_/ / /_/ /_____/ |/ / / / / /_/ |_/_____/\____/ \____/\____/ |___/_/ /_/ NEO-GO-VM > loadgo ./1-print/1-print.go READY: loaded 21 instructions NEO-GO-VM 0 > run 2022-10-07T15:28:20.461+0300 INFO runtime log {"tx": "", "script": "db03ceb3f672ee8cd0d714989b4d103ff7eed2f3", "msg": "Hello, world!"} [] ```
28 lines
929 B
Go
28 lines
929 B
Go
package options
|
|
|
|
import "go.uber.org/zap/zapcore"
|
|
|
|
// FilteringCore is custom implementation of zapcore.Core that allows to filter
|
|
// log entries using custom filtering function.
|
|
type FilteringCore struct {
|
|
zapcore.Core
|
|
filter FilterFunc
|
|
}
|
|
|
|
// FilterFunc is the filter function that is called to check whether the given
|
|
// entry together with the associated fields is to be written to a core or not.
|
|
type FilterFunc func(zapcore.Entry) bool
|
|
|
|
// NewFilteringCore returns a core middleware that uses the given filter function
|
|
// to decide whether to log this message or not.
|
|
func NewFilteringCore(next zapcore.Core, filter FilterFunc) zapcore.Core {
|
|
return &FilteringCore{next, filter}
|
|
}
|
|
|
|
// Check implements zapcore.Core interface and performs log entries filtering.
|
|
func (c *FilteringCore) Check(e zapcore.Entry, ce *zapcore.CheckedEntry) *zapcore.CheckedEntry {
|
|
if c.filter(e) {
|
|
return c.Core.Check(e, ce)
|
|
}
|
|
return ce
|
|
}
|