| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | /* | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 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 defines logging for grpc. | 
					
						
							|  |  |  | // | 
					
						
							| 
									
										
										
										
											2024-09-16 11:06:00 +02:00
										 |  |  | // In the default logger, severity level can be set by environment variable | 
					
						
							|  |  |  | // GRPC_GO_LOG_SEVERITY_LEVEL, verbosity level can be set by | 
					
						
							|  |  |  | // GRPC_GO_LOG_VERBOSITY_LEVEL. | 
					
						
							|  |  |  | package grpclog | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"os" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-16 11:06:00 +02:00
										 |  |  | 	"google.golang.org/grpc/grpclog/internal" | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func init() { | 
					
						
							|  |  |  | 	SetLoggerV2(newLoggerV2()) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // V reports whether verbosity level l is at least the requested verbose level. | 
					
						
							|  |  |  | func V(l int) bool { | 
					
						
							| 
									
										
										
										
											2024-09-16 11:06:00 +02:00
										 |  |  | 	return internal.LoggerV2Impl.V(l) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Info logs to the INFO log. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | func Info(args ...any) { | 
					
						
							| 
									
										
										
										
											2024-09-16 11:06:00 +02:00
										 |  |  | 	internal.LoggerV2Impl.Info(args...) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Infof logs to the INFO log. Arguments are handled in the manner of fmt.Printf. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | func Infof(format string, args ...any) { | 
					
						
							| 
									
										
										
										
											2024-09-16 11:06:00 +02:00
										 |  |  | 	internal.LoggerV2Impl.Infof(format, args...) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Infoln logs to the INFO log. Arguments are handled in the manner of fmt.Println. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | func Infoln(args ...any) { | 
					
						
							| 
									
										
										
										
											2024-09-16 11:06:00 +02:00
										 |  |  | 	internal.LoggerV2Impl.Infoln(args...) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Warning logs to the WARNING log. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | func Warning(args ...any) { | 
					
						
							| 
									
										
										
										
											2024-09-16 11:06:00 +02:00
										 |  |  | 	internal.LoggerV2Impl.Warning(args...) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Warningf logs to the WARNING log. Arguments are handled in the manner of fmt.Printf. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | func Warningf(format string, args ...any) { | 
					
						
							| 
									
										
										
										
											2024-09-16 11:06:00 +02:00
										 |  |  | 	internal.LoggerV2Impl.Warningf(format, args...) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Warningln logs to the WARNING log. Arguments are handled in the manner of fmt.Println. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | func Warningln(args ...any) { | 
					
						
							| 
									
										
										
										
											2024-09-16 11:06:00 +02:00
										 |  |  | 	internal.LoggerV2Impl.Warningln(args...) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Error logs to the ERROR log. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | func Error(args ...any) { | 
					
						
							| 
									
										
										
										
											2024-09-16 11:06:00 +02:00
										 |  |  | 	internal.LoggerV2Impl.Error(args...) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Errorf logs to the ERROR log. Arguments are handled in the manner of fmt.Printf. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | func Errorf(format string, args ...any) { | 
					
						
							| 
									
										
										
										
											2024-09-16 11:06:00 +02:00
										 |  |  | 	internal.LoggerV2Impl.Errorf(format, args...) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Errorln logs to the ERROR log. Arguments are handled in the manner of fmt.Println. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | func Errorln(args ...any) { | 
					
						
							| 
									
										
										
										
											2024-09-16 11:06:00 +02:00
										 |  |  | 	internal.LoggerV2Impl.Errorln(args...) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Fatal logs to the FATAL log. Arguments are handled in the manner of fmt.Print. | 
					
						
							|  |  |  | // It calls os.Exit() with exit code 1. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | func Fatal(args ...any) { | 
					
						
							| 
									
										
										
										
											2024-09-16 11:06:00 +02:00
										 |  |  | 	internal.LoggerV2Impl.Fatal(args...) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	// Make sure fatal logs will exit. | 
					
						
							|  |  |  | 	os.Exit(1) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Fatalf logs to the FATAL log. Arguments are handled in the manner of fmt.Printf. | 
					
						
							|  |  |  | // It calls os.Exit() with exit code 1. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | func Fatalf(format string, args ...any) { | 
					
						
							| 
									
										
										
										
											2024-09-16 11:06:00 +02:00
										 |  |  | 	internal.LoggerV2Impl.Fatalf(format, args...) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	// Make sure fatal logs will exit. | 
					
						
							|  |  |  | 	os.Exit(1) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Fatalln logs to the FATAL log. Arguments are handled in the manner of fmt.Println. | 
					
						
							| 
									
										
										
										
											2024-09-16 11:06:00 +02:00
										 |  |  | // It calls os.Exit() with exit code 1. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | func Fatalln(args ...any) { | 
					
						
							| 
									
										
										
										
											2024-09-16 11:06:00 +02:00
										 |  |  | 	internal.LoggerV2Impl.Fatalln(args...) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | 	// Make sure fatal logs will exit. | 
					
						
							|  |  |  | 	os.Exit(1) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Print prints to the logger. Arguments are handled in the manner of fmt.Print. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // Deprecated: use Info. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | func Print(args ...any) { | 
					
						
							| 
									
										
										
										
											2024-09-16 11:06:00 +02:00
										 |  |  | 	internal.LoggerV2Impl.Info(args...) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Printf prints to the logger. Arguments are handled in the manner of fmt.Printf. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // Deprecated: use Infof. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | func Printf(format string, args ...any) { | 
					
						
							| 
									
										
										
										
											2024-09-16 11:06:00 +02:00
										 |  |  | 	internal.LoggerV2Impl.Infof(format, args...) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Println prints to the logger. Arguments are handled in the manner of fmt.Println. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // Deprecated: use Infoln. | 
					
						
							| 
									
										
										
										
											2023-09-18 13:47:28 +01:00
										 |  |  | func Println(args ...any) { | 
					
						
							| 
									
										
										
										
											2024-09-16 11:06:00 +02:00
										 |  |  | 	internal.LoggerV2Impl.Infoln(args...) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // InfoDepth logs to the INFO log at the specified depth. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // # Experimental | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // Notice: This API is EXPERIMENTAL and may be changed or removed in a | 
					
						
							|  |  |  | // later release. | 
					
						
							|  |  |  | func InfoDepth(depth int, args ...any) { | 
					
						
							|  |  |  | 	if internal.DepthLoggerV2Impl != nil { | 
					
						
							|  |  |  | 		internal.DepthLoggerV2Impl.InfoDepth(depth, args...) | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		internal.LoggerV2Impl.Infoln(args...) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // WarningDepth logs to the WARNING log at the specified depth. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // # Experimental | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // Notice: This API is EXPERIMENTAL and may be changed or removed in a | 
					
						
							|  |  |  | // later release. | 
					
						
							|  |  |  | func WarningDepth(depth int, args ...any) { | 
					
						
							|  |  |  | 	if internal.DepthLoggerV2Impl != nil { | 
					
						
							|  |  |  | 		internal.DepthLoggerV2Impl.WarningDepth(depth, args...) | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		internal.LoggerV2Impl.Warningln(args...) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // ErrorDepth logs to the ERROR log at the specified depth. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // # Experimental | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // Notice: This API is EXPERIMENTAL and may be changed or removed in a | 
					
						
							|  |  |  | // later release. | 
					
						
							|  |  |  | func ErrorDepth(depth int, args ...any) { | 
					
						
							|  |  |  | 	if internal.DepthLoggerV2Impl != nil { | 
					
						
							|  |  |  | 		internal.DepthLoggerV2Impl.ErrorDepth(depth, args...) | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		internal.LoggerV2Impl.Errorln(args...) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // FatalDepth logs to the FATAL log at the specified depth. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // # Experimental | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // Notice: This API is EXPERIMENTAL and may be changed or removed in a | 
					
						
							|  |  |  | // later release. | 
					
						
							|  |  |  | func FatalDepth(depth int, args ...any) { | 
					
						
							|  |  |  | 	if internal.DepthLoggerV2Impl != nil { | 
					
						
							|  |  |  | 		internal.DepthLoggerV2Impl.FatalDepth(depth, args...) | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		internal.LoggerV2Impl.Fatalln(args...) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	os.Exit(1) | 
					
						
							| 
									
										
										
										
											2023-05-09 19:19:48 +02:00
										 |  |  | } |