status-go/vendor/github.com/anacrolix/log/msgimpl.go

34 lines
836 B
Go
Raw Normal View History

2022-03-10 09:44:48 +00:00
package log
import (
"runtime"
)
2024-05-30 08:52:57 +00:00
type valueIterCallback func(value interface{}) (more bool)
2022-03-10 09:44:48 +00:00
// The minimal interface required for the Msg helper/wrapper to operate on.
type MsgImpl interface {
// Returns the message text. Allows for lazy evaluation/prefixing etc.
Text() string
// Sets the program counters in pc. Having it in the interface may allow us to cache/freeze them
// for serialization etc.
Callers(skip int, pc []uintptr) int
// Iterates over the values as added LIFO.
2024-05-30 08:52:57 +00:00
Values(callback valueIterCallback)
2022-03-10 09:44:48 +00:00
}
// maybe implement finalizer to ensure msgs are sunk
type rootMsgImpl struct {
text func() string
}
func (m rootMsgImpl) Text() string {
return m.text()
}
func (m rootMsgImpl) Callers(skip int, pc []uintptr) int {
return runtime.Callers(skip+2, pc)
}
2024-05-30 08:52:57 +00:00
func (m rootMsgImpl) Values(valueIterCallback) {}