logger

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2022 License: MIT Imports: 14 Imported by: 0

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

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 Debug

func Debug(args ...interface{})

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

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 Error

func Error(args ...interface{})

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

func ErrorWithTrace

func ErrorWithTrace(ctx context.Context, args ...interface{})

func Errorf

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

Errorf uses fmt.Sprintf to log a templated message.

func ErrorfWithTrace

func ErrorfWithTrace(ctx context.Context, template string, args ...interface{})

func Errort

func Errort(template string, args ...interface{}) error

Errort uses fmt.Sprintf to log a templated message.

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 Info

func Info(args ...interface{})

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

func InfoWithTrace

func InfoWithTrace(ctx context.Context, args ...interface{})

func Infof

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

Infof uses fmt.Sprintf to log a templated message.

func InfofWithTrace

func InfofWithTrace(ctx context.Context, template string, args ...interface{})

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 JSON

func JSON(msg string, data interface{})

JSON logs a struct data

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 Warn

func Warn(args ...interface{})

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

func WarnWithTrace

func WarnWithTrace(ctx context.Context, args ...interface{})

func Warnf

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

Warnf uses fmt.Sprintf to log a templated message.

func WarnfWithTrace

func WarnfWithTrace(ctx context.Context, template string, args ...interface{})

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 Wrap

func Wrap(router *gin.Engine)

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

func ConfigureLogger(logOptions *Options) *DemoLog

func (*DemoLog) Error

func (d *DemoLog) Error(msg string)

func (*DemoLog) Infof

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

type LogLevel

type LogLevel string

func (LogLevel) Level

func (l LogLevel) Level() zap.AtomicLevel

type Logger

type Logger interface {
	// Error logs a message at error priority
	Error(msg string)

	// Infof logs a message at info priority
	Infof(msg string, args ...interface{})
}

type Options

type Options struct {
	Config
	// contains filtered or unexported fields
}

func (*Options) CompareOptions

func (o *Options) CompareOptions() string

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

Jump to

Keyboard shortcuts

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