mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-28 07:09:57 +00:00
TUN-528: Move cloudflared into a separate repo
This commit is contained in:
49
vendor/zombiezen.com/go/capnproto2/rpc/log.go
generated
vendored
Normal file
49
vendor/zombiezen.com/go/capnproto2/rpc/log.go
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// A Logger records diagnostic information and errors that are not
|
||||
// associated with a call. The arguments passed into a log call are
|
||||
// interpreted like fmt.Printf. They should not be held onto past the
|
||||
// call's return.
|
||||
type Logger interface {
|
||||
Infof(ctx context.Context, format string, args ...interface{})
|
||||
Errorf(ctx context.Context, format string, args ...interface{})
|
||||
}
|
||||
|
||||
type defaultLogger struct{}
|
||||
|
||||
func (defaultLogger) Infof(ctx context.Context, format string, args ...interface{}) {
|
||||
log.Printf("rpc: "+format, args...)
|
||||
}
|
||||
|
||||
func (defaultLogger) Errorf(ctx context.Context, format string, args ...interface{}) {
|
||||
log.Printf("rpc: "+format, args...)
|
||||
}
|
||||
|
||||
func (c *Conn) infof(format string, args ...interface{}) {
|
||||
if c.log == nil {
|
||||
return
|
||||
}
|
||||
c.log.Infof(c.bg, format, args...)
|
||||
}
|
||||
|
||||
func (c *Conn) errorf(format string, args ...interface{}) {
|
||||
if c.log == nil {
|
||||
return
|
||||
}
|
||||
c.log.Errorf(c.bg, format, args...)
|
||||
}
|
||||
|
||||
// ConnLog sets the connection's log to the given Logger, which may be
|
||||
// nil to disable logging. By default, logs are sent to the standard
|
||||
// log package.
|
||||
func ConnLog(log Logger) ConnOption {
|
||||
return ConnOption{func(c *connParams) {
|
||||
c.log = log
|
||||
}}
|
||||
}
|
Reference in New Issue
Block a user