/* * * 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.typeLoggerV2internal.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 {returninternal.NewLoggerV2(, , , internal.LoggerV2Config{})}// NewLoggerV2WithVerbosity creates a loggerV2 with the provided writers and// verbosity level.func (, , io.Writer, int) LoggerV2 {returninternal.NewLoggerV2(, , , internal.LoggerV2Config{Verbosity: })}// newLoggerV2 creates a loggerV2 to be used as default logger.// All logs are written to stderr.func newLoggerV2() 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 }varint := os.Getenv("GRPC_GO_LOG_VERBOSITY_LEVEL")if , := strconv.Atoi(); == nil { = } := strings.EqualFold(os.Getenv("GRPC_GO_LOG_FORMATTER"), "json")returninternal.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.typeDepthLoggerV2internal.DepthLoggerV2
The pages are generated with Goldsv0.8.2. (GOOS=linux 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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds.