Source File
loggerv2.go
Belonging Package
google.golang.org/grpc/grpclog
/*** Copyright 2017 gRPC authors.** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at** http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.**/package grpclogimport ()// LoggerV2 does underlying logging work for grpclog.type LoggerV2 internal.LoggerV2// SetLoggerV2 sets logger that is used in grpc to a V2 logger.// Not mutex-protected, should be called before any gRPC functions.func ( LoggerV2) {if , := .(*componentData); {panic("cannot use component logger as grpclog logger")}internal.LoggerV2Impl =internal.DepthLoggerV2Impl, _ = .(internal.DepthLoggerV2)}// NewLoggerV2 creates a loggerV2 with the provided writers.// Fatal logs will be written to errorW, warningW, infoW, followed by exit(1).// Error logs will be written to errorW, warningW and infoW.// Warning logs will be written to warningW and infoW.// Info logs will be written to infoW.func (, , io.Writer) LoggerV2 {return internal.NewLoggerV2(, , , internal.LoggerV2Config{})}// NewLoggerV2WithVerbosity creates a loggerV2 with the provided writers and// verbosity level.func (, , io.Writer, int) LoggerV2 {return internal.NewLoggerV2(, , , internal.LoggerV2Config{Verbosity: })}// newLoggerV2 creates a loggerV2 to be used as default logger.// All logs are written to stderr.func () LoggerV2 {:= io.Discard:= io.Discard:= io.Discard:= os.Getenv("GRPC_GO_LOG_SEVERITY_LEVEL")switch {case "", "ERROR", "error": // If env is unset, set level to ERROR.= os.Stderrcase "WARNING", "warning":= os.Stderrcase "INFO", "info":= os.Stderr}var int:= os.Getenv("GRPC_GO_LOG_VERBOSITY_LEVEL")if , := strconv.Atoi(); == nil {=}:= strings.EqualFold(os.Getenv("GRPC_GO_LOG_FORMATTER"), "json")return internal.NewLoggerV2(, , , internal.LoggerV2Config{Verbosity: ,FormatJSON: ,})}// DepthLoggerV2 logs at a specified call frame. If a LoggerV2 also implements// DepthLoggerV2, the below functions will be called with the appropriate stack// depth set for trivial functions the logger may ignore.//// # Experimental//// Notice: This type is EXPERIMENTAL and may be changed or removed in a// later release.type DepthLoggerV2 internal.DepthLoggerV2
The pages are generated with Golds v0.7.6. (GOOS=linux GOARCH=amd64)