log

package
v1.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 12 Imported by: 4

Documentation

Overview

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You 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.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You 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.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You 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.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You 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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

Debug uses the fmt.Sprint to construct and log a message using the DefaultLogger.

func Debugf

func Debugf(template string, args ...interface{})

Debugf uses the fmt.Sprintf to log a templated message using the DefaultLogger.

func Debugw

func Debugw(message string, fields ...zapcore.Field)

Debugw logs a message with some additional context using the DefaultLogger.

func Error

func Error(args ...interface{})

Error uses the fmt.Sprint to construct and log a message using the DefaultLogger.

func Errorf

func Errorf(template string, args ...interface{})

Errorf uses the fmt.Sprintf to log a templated message using the DefaultLogger.

func Errorw

func Errorw(message string, fields ...zapcore.Field)

Errorw logs a message with some additional context using the DefaultLogger.

func Fatal

func Fatal(args ...interface{})

Fatal uses the fmt.Sprint to construct and log a message using the DefaultLogger.

func Fatalf

func Fatalf(template string, args ...interface{})

Fatalf uses the fmt.Sprintf to log a templated message using the DefaultLogger.

func Fatalw

func Fatalw(message string, fields ...zapcore.Field)

Fatalw logs a message with some additional context using the DefaultLogger.

func GinLogger added in v1.7.0

func GinLogger() gin.HandlerFunc

GinLogger receive gin The default log of the framework

func GinRecovery added in v1.7.0

func GinRecovery(stack bool) gin.HandlerFunc

GinRecovery recover Drop the project that may appear panic

func Info

func Info(args ...interface{})

Info uses the fmt.Sprint to construct and log a message using the DefaultLogger.

func Infof

func Infof(template string, args ...interface{})

Infof uses the fmt.Sprintf to log a templated message using the DefaultLogger.

func Infow

func Infow(message string, fields ...zapcore.Field)

Infow logs a message with some additional context using the DefaultLogger.

func Level added in v1.7.0

func Level() zapcore.Level

Level returns the DefaultLogger log level

func Panic

func Panic(args ...interface{})

Panic uses the fmt.Sprint to construct and log a message using the DefaultLogger.

func Panicf

func Panicf(template string, args ...interface{})

Panicf uses the fmt.Sprintf to log a templated message using the DefaultLogger.

func Panicw

func Panicw(message string, fields ...zapcore.Field)

Panicw logs a message with some additional context using the DefaultLogger.

func Warn

func Warn(args ...interface{})

Warn uses the fmt.Sprint to construct and log a message using the DefaultLogger.

func Warnf

func Warnf(template string, args ...interface{})

Warnf uses the fmt.Sprintf to log a templated message using the DefaultLogger.

func Warnw

func Warnw(message string, fields ...zapcore.Field)

Warnw logs a message with some additional context using the DefaultLogger.

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger is a log object, which exposes standard APIs like errorf, error, warn, warnf and etcd.

var (
	// DefaultLogger is the default logger, which logs message to stderr and with
	// the minimal level "warn".
	DefaultLogger *Logger
)

func NewLogger

func NewLogger(opts ...Option) (*Logger, error)

NewLogger sets up a Logger object according to a series of options.

func (*Logger) Close

func (logger *Logger) Close() (err error)

Close flushes all buffered logs and closes the underlying writer.

func (*Logger) Debug

func (logger *Logger) Debug(args ...interface{})

Debug uses the fmt.Sprint to construct and log a message.

func (*Logger) Debugf

func (logger *Logger) Debugf(template string, args ...interface{})

Debugf uses the fmt.Sprintf to log a templated message.

func (*Logger) Debugw

func (logger *Logger) Debugw(message string, fields ...zapcore.Field)

Debugw logs a message with some additional context.

func (*Logger) Error

func (logger *Logger) Error(args ...interface{})

Error uses the fmt.Sprint to construct and log a message.

func (*Logger) Errorf

func (logger *Logger) Errorf(template string, args ...interface{})

Errorf uses the fmt.Sprintf to log a templated message.

func (*Logger) Errorw

func (logger *Logger) Errorw(message string, fields ...zapcore.Field)

Errorw logs a message with some additional context.

func (*Logger) Fatal

func (logger *Logger) Fatal(args ...interface{})

Fatal uses the fmt.Sprint to construct and log a message.

func (*Logger) Fatalf

func (logger *Logger) Fatalf(template string, args ...interface{})

Fatalf uses the fmt.Sprintf to log a templated message.

func (*Logger) Fatalw

func (logger *Logger) Fatalw(message string, fields ...zapcore.Field)

Fatalw logs a message with some additional context.

func (*Logger) Info

func (logger *Logger) Info(args ...interface{})

Info uses the fmt.Sprint to construct and log a message.

func (*Logger) Infof

func (logger *Logger) Infof(template string, args ...interface{})

Infof uses the fmt.Sprintf to log a templated message.

func (*Logger) Infow

func (logger *Logger) Infow(message string, fields ...zapcore.Field)

Infow logs a message with some additional context.

func (*Logger) Level added in v1.7.0

func (logger *Logger) Level() zapcore.Level

Level returns the log level

func (*Logger) Panic

func (logger *Logger) Panic(args ...interface{})

Panic uses the fmt.Sprint to construct and log a message.

func (*Logger) Panicf

func (logger *Logger) Panicf(template string, args ...interface{})

Panicf uses the fmt.Sprintf to log a templated message.

func (*Logger) Panicw

func (logger *Logger) Panicw(message string, fields ...zapcore.Field)

Panicw logs a message with some additional context.

func (*Logger) Sync

func (logger *Logger) Sync() (err error)

Sync flushes all buffered logs to the their destination.

func (*Logger) Warn

func (logger *Logger) Warn(args ...interface{})

Warn uses the fmt.Sprint to construct and log a message.

func (*Logger) Warnf

func (logger *Logger) Warnf(template string, args ...interface{})

Warnf uses the fmt.Sprintf to log a templated message.

func (*Logger) Warnw

func (logger *Logger) Warnw(message string, fields ...zapcore.Field)

Warnw logs a message with some additional context.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option configures how to set up logger.

func WithLogLevel

func WithLogLevel(level string) Option

WithLogLevel sets the log level.

func WithOutputFile

func WithOutputFile(file string) Option

WithOutputFile sets the output file path.

func WithWriteSyncer

func WithWriteSyncer(ws zapcore.WriteSyncer) Option

WithWriteSyncer is a low level API which sets the underlying WriteSyncer by providing a zapcore.WriterSyncer, which has high priority than WithOutputFile.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL