package binarylog
Import Path
google.golang.org/grpc/internal/binarylog (on go.dev)
Dependency Relation
imports 21 packages, and imported by one package
Involved Source Files
Package binarylog implementation binary logging as defined in
https://github.com/grpc/proposal/blob/master/A16-binary-logging.md.
binarylog_testutil.go
env_config.go
method_logger.go
sink.go
Package-Level Type Names (total 17, in which 11 are exported)
Cancel configs the binary log entry to be a Cancel entry.
OnClientSide bool
(*T) toProto() *pb.GrpcLogEntry
*T : LogEntryConfig
ClientHalfClose configs the binary log entry to be a ClientHalfClose entry.
OnClientSide bool
(*T) toProto() *pb.GrpcLogEntry
*T : LogEntryConfig
ClientHeader configs the binary log entry to be a ClientHeader entry.
Authority string
Header metadata.MD
MethodName string
OnClientSide bool
PeerAddr is required only when it's on server side.
Timeout time.Duration
(*T) toProto() *pb.GrpcLogEntry
*T : LogEntryConfig
ClientMessage configs the binary log entry to be a ClientMessage entry.
Message can be a proto.Message or []byte. Other messages formats are not
supported.
OnClientSide bool
(*T) toProto() *pb.GrpcLogEntry
*T : LogEntryConfig
LogEntryConfig represents the configuration for binary log entry.
( T) toProto() *pb.GrpcLogEntry
*Cancel
*ClientHalfClose
*ClientHeader
*ClientMessage
*ServerHeader
*ServerMessage
*ServerTrailer
func (*MethodLogger).Log(c LogEntryConfig)
Logger is the global binary logger. It can be used to get binary logger for
each method.
( T) getMethodLogger(methodName string) *MethodLogger
*logger
func NewLoggerFromConfigString(s string) Logger
func SetLogger(l Logger)
var AllLogger
var binLogger
MethodLogger is the sub-logger for each method.
callID uint64
headerMaxLen uint64
idWithinCallGen *callIDGenerator
messageMaxLen uint64
// TODO(blog): make this plugable.
Log creates a proto binary log entry, and logs it to the sink.
(*T) truncateMessage(msgPb *pb.Message) (truncated bool)
(*T) truncateMetadata(mdPb *pb.Metadata) (truncated bool)
func GetMethodLogger(methodName string) *MethodLogger
func newMethodLogger(h, m uint64) *MethodLogger
ServerHeader configs the binary log entry to be a ServerHeader entry.
Header metadata.MD
OnClientSide bool
PeerAddr is required only when it's on client side.
(*T) toProto() *pb.GrpcLogEntry
*T : LogEntryConfig
ServerMessage configs the binary log entry to be a ServerMessage entry.
Message can be a proto.Message or []byte. Other messages formats are not
supported.
OnClientSide bool
(*T) toProto() *pb.GrpcLogEntry
*T : LogEntryConfig
ServerTrailer configs the binary log entry to be a ServerTrailer entry.
Err is the status error.
OnClientSide bool
PeerAddr is required only when it's on client side and the RPC is trailer
only.
Trailer metadata.MD
(*T) toProto() *pb.GrpcLogEntry
*T : LogEntryConfig
Sink writes log entry into the binary log sink.
Close will be called when the Sink is replaced by a new Sink.
Write will be called to write the log entry into the sink.
It should be thread-safe so it can be called in parallel.
*bufWriteCloserSink
*noopSink
*writerSink
T : io.Closer
func NewTempFileSink() (Sink, error)
func newBufWriteCloserSink(o io.WriteCloser) Sink
func SetDefaultSink(s Sink)
var defaultSink
Package-Level Functions (total 15, in which 5 are exported)
GetMethodLogger returns the methodLogger for the given methodName.
methodName should be in the format of "/service/method".
Each methodLogger returned by this method is a new instance. This is to
generate sequence id within the call.
NewLoggerFromConfigString reads the string and build a logger. It can be used
to build a new logger and assign it to binarylog.Logger.
Example filter config strings:
- "" Nothing will be logged
- "*" All headers and messages will be fully logged.
- "*{h}" Only headers will be logged.
- "*{m:256}" Only the first 256 bytes of each message will be logged.
- "Foo/*" Logs every method in service Foo
- "Foo/*,-Foo/Bar" Logs every method in service Foo except method /Foo/Bar
- "Foo/*,Foo/Bar{m:256}" Logs the first 256 bytes of each message in method
/Foo/Bar, logs all headers and messages in every other method in service
Foo.
If two configs exist for one certain method or service, the one specified
later overrides the previous config.
NewTempFileSink creates a temp file and returns a Sink that writes to this
file.
SetDefaultSink sets the sink where binary logs will be written to.
Not thread safe. Only set during initialization.
SetLogger sets the binarg logger.
Only call this at init time.
Package-Level Variables (total 11, in which 3 are exported)
AddrToProto converts an address to a binary logging proto message. It's
for testing only.
AllLogger is a logger that logs all headers/messages for all RPCs. It's
for testing only.
MdToMetadataProto converts metadata to a binary logging proto message.
It's for testing only.
Package-Level Constants (total 7, none are exported)
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |