gotosocial/vendor/google.golang.org/grpc/grpclog/grpclog.go

187 lines
5.1 KiB
Go
Raw Permalink Normal View History

2023-05-09 17:19:48 +00: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.
//
// 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 17:19:48 +00:00
import (
"os"
"google.golang.org/grpc/grpclog/internal"
2023-05-09 17:19:48 +00:00
)
func init() {
SetLoggerV2(newLoggerV2())
}
// V reports whether verbosity level l is at least the requested verbose level.
func V(l int) bool {
return internal.LoggerV2Impl.V(l)
2023-05-09 17:19:48 +00:00
}
// Info logs to the INFO log.
func Info(args ...any) {
internal.LoggerV2Impl.Info(args...)
2023-05-09 17:19:48 +00:00
}
// Infof logs to the INFO log. Arguments are handled in the manner of fmt.Printf.
func Infof(format string, args ...any) {
internal.LoggerV2Impl.Infof(format, args...)
2023-05-09 17:19:48 +00:00
}
// Infoln logs to the INFO log. Arguments are handled in the manner of fmt.Println.
func Infoln(args ...any) {
internal.LoggerV2Impl.Infoln(args...)
2023-05-09 17:19:48 +00:00
}
// Warning logs to the WARNING log.
func Warning(args ...any) {
internal.LoggerV2Impl.Warning(args...)
2023-05-09 17:19:48 +00:00
}
// Warningf logs to the WARNING log. Arguments are handled in the manner of fmt.Printf.
func Warningf(format string, args ...any) {
internal.LoggerV2Impl.Warningf(format, args...)
2023-05-09 17:19:48 +00:00
}
// Warningln logs to the WARNING log. Arguments are handled in the manner of fmt.Println.
func Warningln(args ...any) {
internal.LoggerV2Impl.Warningln(args...)
2023-05-09 17:19:48 +00:00
}
// Error logs to the ERROR log.
func Error(args ...any) {
internal.LoggerV2Impl.Error(args...)
2023-05-09 17:19:48 +00:00
}
// Errorf logs to the ERROR log. Arguments are handled in the manner of fmt.Printf.
func Errorf(format string, args ...any) {
internal.LoggerV2Impl.Errorf(format, args...)
2023-05-09 17:19:48 +00:00
}
// Errorln logs to the ERROR log. Arguments are handled in the manner of fmt.Println.
func Errorln(args ...any) {
internal.LoggerV2Impl.Errorln(args...)
2023-05-09 17:19:48 +00:00
}
// Fatal logs to the FATAL log. Arguments are handled in the manner of fmt.Print.
// It calls os.Exit() with exit code 1.
func Fatal(args ...any) {
internal.LoggerV2Impl.Fatal(args...)
2023-05-09 17:19:48 +00: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.
func Fatalf(format string, args ...any) {
internal.LoggerV2Impl.Fatalf(format, args...)
2023-05-09 17:19:48 +00: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.
// It calls os.Exit() with exit code 1.
func Fatalln(args ...any) {
internal.LoggerV2Impl.Fatalln(args...)
2023-05-09 17:19:48 +00: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.
func Print(args ...any) {
internal.LoggerV2Impl.Info(args...)
2023-05-09 17:19:48 +00:00
}
// Printf prints to the logger. Arguments are handled in the manner of fmt.Printf.
//
// Deprecated: use Infof.
func Printf(format string, args ...any) {
internal.LoggerV2Impl.Infof(format, args...)
2023-05-09 17:19:48 +00:00
}
// Println prints to the logger. Arguments are handled in the manner of fmt.Println.
//
// Deprecated: use Infoln.
func Println(args ...any) {
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 17:19:48 +00:00
}