Documentation ¶
Overview ¶
Package log output logged entries to respective logging hooks
Package log provide the logging interfaces
Index ¶
- Constants
- func Close()
- func Debugf(format string, args ...interface{})
- func Debugln(args ...interface{})
- func EnsureGRPCContext(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (interface{}, error)
- func Errorf(format string, args ...interface{})
- func Errorln(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Fatalln(args ...interface{})
- func FilteredLog(ctx context.Context, isSkip, isDebug bool, msg string)
- func Flush()
- func Infof(format string, args ...interface{})
- func Infoln(args ...interface{})
- func InitLogging(req *LoggingRequest) error
- func MockInitLogging(logName string)
- func MockStopLogging(logName string)
- func SetRequestInfo(ctx context.Context) (context.Context, error)
- func SetRequestInfoWithTag(ctx context.Context, tag string) (context.Context, error)
- func Warningf(format string, args ...interface{})
- func Warningln(args ...interface{})
- type ConsoleHook
- type FileHook
- type Logger
- type LoggingInterface
- type LoggingRequest
- type PlainTextFormatter
Constants ¶
const ( // CsiRequestID use to mark requestId for log printer CsiRequestID key = "csi.requestid" // TagNameKey use to mark tag name key TagNameKey key = "csi.tag" // TagName use to mark tag for log printer TagName = "tag" )
Variables ¶
This section is empty.
Functions ¶
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf ensures output of formatted debug logs
func EnsureGRPCContext ¶
func EnsureGRPCContext(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
EnsureGRPCContext ensures adding request id in incoming context
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf ensures output of formatted error logs
func Fatalf ¶
func Fatalf(format string, args ...interface{})
Fatalf ensures output of formatted fatal logs
func FilteredLog ¶
FilteredLog will not print the logs that need to be filtered, and the log level will be as required.
func Infof ¶
func Infof(format string, args ...interface{})
Infof ensures output of formatted info logs
func InitLogging ¶
func InitLogging(req *LoggingRequest) error
InitLogging configures logging. Logs are written to a log file or stdout/stderr. Since logrus doesn't support multiple writers, each log stream is implemented as a hook.
func MockInitLogging ¶
func MockInitLogging(logName string)
MockInitLogging mock init the logging service
func MockStopLogging ¶
func MockStopLogging(logName string)
MockStopLogging mock stop the logging service
func SetRequestInfo ¶
SetRequestInfo used to set the context with value
func SetRequestInfoWithTag ¶
SetRequestInfoWithTag set request tag
Types ¶
type ConsoleHook ¶
type ConsoleHook struct {
// contains filtered or unexported fields
}
ConsoleHook sends log entries to stdout/stderr.
func (*ConsoleHook) Fire ¶
func (hook *ConsoleHook) Fire(entry *logrus.Entry) error
Fire ensure logging of respective log entries
func (*ConsoleHook) Levels ¶
func (hook *ConsoleHook) Levels() []logrus.Level
Levels returns all supported levels
type FileHook ¶
type FileHook struct {
// contains filtered or unexported fields
}
FileHook sends log entries to a file.
type Logger ¶
type Logger interface { Debugf(format string, args ...interface{}) Debugln(args ...interface{}) Infof(format string, args ...interface{}) Infoln(args ...interface{}) Warningf(format string, args ...interface{}) Warningln(args ...interface{}) Errorf(format string, args ...interface{}) Errorln(args ...interface{}) Fatalf(format string, args ...interface{}) Fatalln(args ...interface{}) }
Logger exposes logging functionality
func AddContext ¶
AddContext ensures appending context info in log
type LoggingInterface ¶
type LoggingInterface interface { Logger AddContext(ctx context.Context) Logger // contains filtered or unexported methods }
LoggingInterface is an interface exposes logging functionality
type LoggingRequest ¶
type LoggingRequest struct { LogName string LogFileSize string LoggingModule string LogLevel string LogFileDir string MaxBackups uint }
LoggingRequest use to init the logging service
type PlainTextFormatter ¶
type PlainTextFormatter struct { // TimestampFormat to use for display when a full timestamp is printed TimestampFormat string // contains filtered or unexported fields }
PlainTextFormatter is a formatter to ensure formatted logging output