| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | /* | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright 2020 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 (internal) defines depth logging for grpc. | 
					
						
							|  |  |  | package grpclog | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"os" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Logger is the logger used for the non-depth log functions. | 
					
						
							|  |  |  | var Logger LoggerV2 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // DepthLogger is the logger used for the depth log functions. | 
					
						
							|  |  |  | var DepthLogger DepthLoggerV2 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // InfoDepth logs to the INFO log at the specified depth. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | func InfoDepth(depth int, args ...any) { | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	if DepthLogger != nil { | 
					
						
							|  |  |  | 		DepthLogger.InfoDepth(depth, args...) | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		Logger.Infoln(args...) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // WarningDepth logs to the WARNING log at the specified depth. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | func WarningDepth(depth int, args ...any) { | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	if DepthLogger != nil { | 
					
						
							|  |  |  | 		DepthLogger.WarningDepth(depth, args...) | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		Logger.Warningln(args...) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // ErrorDepth logs to the ERROR log at the specified depth. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | func ErrorDepth(depth int, args ...any) { | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	if DepthLogger != nil { | 
					
						
							|  |  |  | 		DepthLogger.ErrorDepth(depth, args...) | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		Logger.Errorln(args...) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // FatalDepth logs to the FATAL log at the specified depth. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | func FatalDepth(depth int, args ...any) { | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	if DepthLogger != nil { | 
					
						
							|  |  |  | 		DepthLogger.FatalDepth(depth, args...) | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		Logger.Fatalln(args...) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	os.Exit(1) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // LoggerV2 does underlying logging work for grpclog. | 
					
						
							|  |  |  | // This is a copy of the LoggerV2 defined in the external grpclog package. It | 
					
						
							|  |  |  | // is defined here to avoid a circular dependency. | 
					
						
							|  |  |  | type LoggerV2 interface { | 
					
						
							|  |  |  | 	// Info logs to INFO log. Arguments are handled in the manner of fmt.Print. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | 	Info(args ...any) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	// Infoln logs to INFO log. Arguments are handled in the manner of fmt.Println. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | 	Infoln(args ...any) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	// Infof logs to INFO log. Arguments are handled in the manner of fmt.Printf. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | 	Infof(format string, args ...any) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	// Warning logs to WARNING log. Arguments are handled in the manner of fmt.Print. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | 	Warning(args ...any) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	// Warningln logs to WARNING log. Arguments are handled in the manner of fmt.Println. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | 	Warningln(args ...any) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	// Warningf logs to WARNING log. Arguments are handled in the manner of fmt.Printf. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | 	Warningf(format string, args ...any) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	// Error logs to ERROR log. Arguments are handled in the manner of fmt.Print. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | 	Error(args ...any) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	// Errorln logs to ERROR log. Arguments are handled in the manner of fmt.Println. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | 	Errorln(args ...any) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	// Errorf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | 	Errorf(format string, args ...any) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	// 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. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | 	Fatal(args ...any) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	// 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. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | 	Fatalln(args ...any) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	// 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. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | 	Fatalf(format string, args ...any) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	// V reports whether verbosity level l is at least the requested verbose level. | 
					
						
							|  |  |  | 	V(l int) bool | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // 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 is a copy of the DepthLoggerV2 defined in the external grpclog package. | 
					
						
							|  |  |  | // It is defined here to avoid a circular dependency. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // # Experimental | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // Notice: This type is EXPERIMENTAL and may be changed or removed in a | 
					
						
							|  |  |  | // later release. | 
					
						
							|  |  |  | type DepthLoggerV2 interface { | 
					
						
							|  |  |  | 	// InfoDepth logs to INFO log at the specified depth. Arguments are handled in the manner of fmt.Println. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | 	InfoDepth(depth int, args ...any) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	// WarningDepth logs to WARNING log at the specified depth. Arguments are handled in the manner of fmt.Println. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | 	WarningDepth(depth int, args ...any) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	// ErrorDepth logs to ERROR log at the specified depth. Arguments are handled in the manner of fmt.Println. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | 	ErrorDepth(depth int, args ...any) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	// FatalDepth logs to FATAL log at the specified depth. Arguments are handled in the manner of fmt.Println. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | 	FatalDepth(depth int, args ...any) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | } |