* * 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 grpclog

import (
	
	
	
	
	

	
)
LoggerV2 does underlying logging work for grpclog.
Info logs to INFO log. Arguments are handled in the manner of fmt.Print.
Infoln logs to INFO log. Arguments are handled in the manner of fmt.Println.
Infof logs to INFO log. Arguments are handled in the manner of fmt.Printf.
Warning logs to WARNING log. Arguments are handled in the manner of fmt.Print.
Warningln logs to WARNING log. Arguments are handled in the manner of fmt.Println.
Warningf logs to WARNING log. Arguments are handled in the manner of fmt.Printf.
Error logs to ERROR log. Arguments are handled in the manner of fmt.Print.
Errorln logs to ERROR log. Arguments are handled in the manner of fmt.Println.
Errorf logs to ERROR log. Arguments are handled in the manner of fmt.Printf.
Fatal logs to ERROR log. Arguments are handled in the manner of fmt.Print. gRPC ensures that all Fatal logs will exit with os.Exit(1). Implementations may also call os.Exit() with a non-zero exit code.
Fatalln logs to ERROR log. Arguments are handled in the manner of fmt.Println. gRPC ensures that all Fatal logs will exit with os.Exit(1). Implementations may also call os.Exit() with a non-zero exit code.
Fatalf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. gRPC ensures that all Fatal logs will exit with os.Exit(1). Implementations may also call os.Exit() with a non-zero exit code.
V reports whether verbosity level l is at least the requested verbose level.
	V(l int) bool
}
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")
	}
	grpclog.Logger = 
	grpclog.DepthLogger, _ = .(grpclog.DepthLoggerV2)
}

infoLog indicates Info severity.
warningLog indicates Warning severity.
errorLog indicates Error severity.
fatalLog indicates Fatal severity.
severityName contains the string representation of each severity.
var severityName = []string{
	infoLog:    "INFO",
	warningLog: "WARNING",
	errorLog:   "ERROR",
	fatalLog:   "FATAL",
}
loggerT is the default logger used by grpclog.
type loggerT struct {
	m []*log.Logger
	v int
}
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 NewLoggerV2WithVerbosity(, , , 0)
}
NewLoggerV2WithVerbosity creates a loggerV2 with the provided writers and verbosity level.
func (, ,  io.Writer,  int) LoggerV2 {
	var  []*log.Logger
	 = append(, log.New(, severityName[infoLog]+": ", log.LstdFlags))
	 = append(, log.New(io.MultiWriter(, ), severityName[warningLog]+": ", log.LstdFlags))
	 := io.MultiWriter(, , ) // ew will be used for error and fatal.
	 = append(, log.New(, severityName[errorLog]+": ", log.LstdFlags))
	 = append(, log.New(, severityName[fatalLog]+": ", log.LstdFlags))
	return &loggerT{m: , v: }
}
newLoggerV2 creates a loggerV2 to be used as default logger. All logs are written to stderr.
func () LoggerV2 {
	 := ioutil.Discard
	 := ioutil.Discard
	 := ioutil.Discard

	 := os.Getenv("GRPC_GO_LOG_SEVERITY_LEVEL")
	switch  {
	case "", "ERROR", "error": // If env is unset, set level to ERROR.
		 = os.Stderr
	case "WARNING", "warning":
		 = os.Stderr
	case "INFO", "info":
		 = os.Stderr
	}

	var  int
	 := os.Getenv("GRPC_GO_LOG_VERBOSITY_LEVEL")
	if ,  := strconv.Atoi();  == nil {
		 = 
	}
	return NewLoggerV2WithVerbosity(, , , )
}

func ( *loggerT) ( ...interface{}) {
	.m[infoLog].Print(...)
}

func ( *loggerT) ( ...interface{}) {
	.m[infoLog].Println(...)
}

func ( *loggerT) ( string,  ...interface{}) {
	.m[infoLog].Printf(, ...)
}

func ( *loggerT) ( ...interface{}) {
	.m[warningLog].Print(...)
}

func ( *loggerT) ( ...interface{}) {
	.m[warningLog].Println(...)
}

func ( *loggerT) ( string,  ...interface{}) {
	.m[warningLog].Printf(, ...)
}

func ( *loggerT) ( ...interface{}) {
	.m[errorLog].Print(...)
}

func ( *loggerT) ( ...interface{}) {
	.m[errorLog].Println(...)
}

func ( *loggerT) ( string,  ...interface{}) {
	.m[errorLog].Printf(, ...)
}

func ( *loggerT) ( ...interface{}) {
No need to call os.Exit() again because log.Logger.Fatal() calls os.Exit().
}

func ( *loggerT) ( ...interface{}) {
No need to call os.Exit() again because log.Logger.Fatal() calls os.Exit().
}

func ( *loggerT) ( string,  ...interface{}) {
No need to call os.Exit() again because log.Logger.Fatal() calls os.Exit().
}

func ( *loggerT) ( int) bool {
	return  <= .v
}
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. This API is EXPERIMENTAL.
type DepthLoggerV2 interface {
InfoDepth logs to INFO log at the specified depth. Arguments are handled in the manner of fmt.Print.
WarningDepth logs to WARNING log at the specified depth. Arguments are handled in the manner of fmt.Print.
ErrorDetph logs to ERROR log at the specified depth. Arguments are handled in the manner of fmt.Print.
FatalDepth logs to FATAL log at the specified depth. Arguments are handled in the manner of fmt.Print.
	FatalDepth(depth int, args ...interface{})