Documentation ¶
Overview ¶
Copyright (c) 2016-2019 Uber Technologies, Inc.
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.
Index ¶
- func DPanic(args ...interface{})
- func DPanicf(template string, args ...interface{})
- func Debug(args ...interface{})
- func Debugf(template string, args ...interface{})
- func Debugw(msg string, keysAndValues ...interface{})
- func Default() *zap.SugaredLogger
- func Error(args ...interface{})
- func ErrorWithTrace(ctx context.Context, args ...interface{})
- func Errorf(template string, args ...interface{})
- func ErrorfWithTrace(ctx context.Context, template string, args ...interface{})
- func Errort(template string, args ...interface{}) error
- func Errorw(msg string, keysAndValues ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(template string, args ...interface{})
- func Fatalw(msg string, keysAndValues ...interface{})
- func GetHandler() gin.HandlerFunc
- func Info(args ...interface{})
- func InfoWithTrace(ctx context.Context, args ...interface{})
- func Infof(template string, args ...interface{})
- func InfofWithTrace(ctx context.Context, template string, args ...interface{})
- func Infow(msg string, keysAndValues ...interface{})
- func JSON(msg string, data interface{})
- func Panic(args ...interface{})
- func Panicf(template string, args ...interface{})
- func Panicw(msg string, keysAndValues ...interface{})
- func PutHandler() gin.HandlerFunc
- func Warn(args ...interface{})
- func WarnWithTrace(ctx context.Context, args ...interface{})
- func Warnf(template string, args ...interface{})
- func WarnfWithTrace(ctx context.Context, template string, args ...interface{})
- func Warnw(msg string, keysAndValues ...interface{})
- func With(args ...interface{}) *zap.SugaredLogger
- func Wrap(router *gin.Engine)
- func WrapGroup(router *gin.RouterGroup)
- type Config
- type DemoLog
- type LogLevel
- type Logger
- type Options
- type ZapConfEncoding
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DPanic ¶
func DPanic(args ...interface{})
DPanic uses fmt.Sprint to construct and log a message. In development, the logger then panics
func DPanicf ¶
func DPanicf(template string, args ...interface{})
DPanicf uses fmt.Sprintf to log a templated message. In development, the logger then panics.
func Debugf ¶
func Debugf(template string, args ...interface{})
Debugf uses fmt.Sprintf to log a templated message.
func Debugw ¶
func Debugw(msg string, keysAndValues ...interface{})
Debugw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.
When debug-level logging is disabled, this is much faster than
s.With(keysAndValues).Debug(msg)
func Default ¶
func Default() *zap.SugaredLogger
func ErrorWithTrace ¶
func Errorf ¶
func Errorf(template string, args ...interface{})
Errorf uses fmt.Sprintf to log a templated message.
func ErrorfWithTrace ¶
func Errorw ¶
func Errorw(msg string, keysAndValues ...interface{})
Errorw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.
func Fatal ¶
func Fatal(args ...interface{})
Fatal uses fmt.Sprint to construct and log a message, then calls os.Exit.
func Fatalf ¶
func Fatalf(template string, args ...interface{})
Fatalf uses fmt.Sprintf to log a templated message, then calls os.Exit.
func Fatalw ¶
func Fatalw(msg string, keysAndValues ...interface{})
Fatalw logs a message with some additional context, then calls os.Exit. The variadic key-value pairs are treated as they are in With.
func GetHandler ¶
func GetHandler() gin.HandlerFunc
func InfoWithTrace ¶
func Infof ¶
func Infof(template string, args ...interface{})
Infof uses fmt.Sprintf to log a templated message.
func InfofWithTrace ¶
func Infow ¶
func Infow(msg string, keysAndValues ...interface{})
Infow logs a message with some additional context. The variadic key-value pairs are treated as they are in With.
func Panic ¶
func Panic(args ...interface{})
Panic uses fmt.Sprint to construct and log a message, then panics.
func Panicf ¶
func Panicf(template string, args ...interface{})
Panicf uses fmt.Sprintf to log a templated message, then panics.
func Panicw ¶
func Panicw(msg string, keysAndValues ...interface{})
Panicw logs a message with some additional context, then panics. The variadic key-value pairs are treated as they are in With.
func PutHandler ¶
func PutHandler() gin.HandlerFunc
func WarnWithTrace ¶
func Warnf ¶
func Warnf(template string, args ...interface{})
Warnf uses fmt.Sprintf to log a templated message.
func WarnfWithTrace ¶
func Warnw ¶
func Warnw(msg string, keysAndValues ...interface{})
Warnw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.
func With ¶
func With(args ...interface{}) *zap.SugaredLogger
With adds a variadic number of fields to the logging context. It accepts a mix of strongly-typed zapcore.Field objects and loosely-typed key-value pairs.
func WrapGroup ¶
func WrapGroup(router *gin.RouterGroup)
Types ¶
type Config ¶
type Config struct { Level LogLevel `yaml:"level" env:"LogLevel" env-default:"info" env-description:"log level"` Encoding ZapConfEncoding `yaml:"encoding" env:"LogEncoding" env-default:"console" env-description:"log encoding"` Development bool `yaml:"development"` EnableTrace bool `yaml:"enable_trace"` LogPath string `yaml:"log_path" env:"LogPath" env-description:"which path the log file should be"` LogName string `yaml:"log_name" env:"LogFileName" env-description:"which file name the log file should be"` MaxSize int `yaml:"max_size" env:"LogMaxSize" env-description:"max size of rotating"` MaxAge int `yaml:"max_age" env:"LogMaxAge" env-description:"max age of rotating"` LocalTime bool `yaml:"localtime"` Compress bool `yaml:"compress" env:"LogCompress" env-description:"compress old log files or not"` }
type DemoLog ¶
type DemoLog struct { *zap.SugaredLogger // contains filtered or unexported fields }
var (
DefaultLog *DemoLog
)
func ConfigureLogger ¶
type LogLevel ¶
type LogLevel string
func (LogLevel) Level ¶
func (l LogLevel) Level() zap.AtomicLevel
type Options ¶
type Options struct { Config // contains filtered or unexported fields }
func (*Options) CompareOptions ¶
type ZapConfEncoding ¶
type ZapConfEncoding string
const ( ZapEncodeJSON ZapConfEncoding = "json" ZapEncodeConsole ZapConfEncoding = "console" )
func (ZapConfEncoding) IsValid ¶
func (code ZapConfEncoding) IsValid() bool
func (ZapConfEncoding) String ¶
func (code ZapConfEncoding) String() string