zaplogger

package module
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2019 License: MIT Imports: 12 Imported by: 22

README

uber-bo/zap logger for fasthttp and glog ....

zap log to console for debug make easy

package main

import (
	"go.uber.org/zap"

	"github.com/tsingson/zaplogger"
)

func main() {
	core := zaplogger.NewConsoleDebug()

	// From a zapcore.Core, it's easy to construct a Logger.
	logger := zap.New(core)
	defer logger.Sync()
	logger.Info("constructed a logger")
}

output

2019-08-01T20:59:41.879+0800    INFO    constructed a logger

add stack trace

package main

import (
	"go.uber.org/zap"

	"github.com/tsingson/zaplogger"
)

func main() {
	core := zaplogger.NewConsoleDebug()

	// From a zapcore.Core, it's easy to construct a Logger.
	logger := zap.New(core).WithOptions(zap.AddCaller())
	defer logger.Sync()
	logger.Info("constructed a logger")
}

output

2019-08-01T21:23:20.549+0800    INFO    example/main.go:15  constructed a logger

Documentation

Index

Constants

This section is empty.

Variables

LogLevel log level

Functions

func ConsoleDebug added in v0.3.2

func ConsoleDebug() *zap.Logger

ConsoleDebug console log for debug

func Debug

func Debug(args ...interface{})

Debug logs a message at level Debug on the ZapLogger.

func Debugf

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

Debugf logs a message at level Debug on the ZapLogger.

func Error

func Error(args ...interface{})

Error logs a message at level Error on the ZapLogger.

func Errorf

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

Errorf logs a message at level Warn on the ZapLogger.

func Fatal

func Fatal(args ...interface{})

Fatal logs a message at level Fatal on the ZapLogger.

func Fatalf

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

Fatalf logs a message at level Warn on the ZapLogger.

func GetCurrentPath

func GetCurrentPath() (string, error)

func Info

func Info(args ...interface{})

Info logs a message at level Info on the ZapLogger.

func Infof

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

Infof logs a message at level Info on the ZapLogger.

func NewConsole added in v0.3.1

func NewConsole() zapcore.Core

NewConsole new zap logger for console

func NewConsoleDebug added in v0.3.1

func NewConsoleDebug() zapcore.Core

NewConsoleDebug new zap logger for console

func NewLogger

func NewLogger() *zap.Logger

NewLogger new zap log

func NewZapLog

func NewZapLog(path, prefix string, stdoutFlag bool) (log *zap.Logger)

NewZapLog init a log

func NewZlog

func NewZlog(debugLevel bool) (logger *zap.Logger)

NewLogger return a normal log

func Panic

func Panic(args ...interface{})

Panic logs a message at level Painc on the ZapLogger.

func Panicf

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

Panicf logs a message at level Warn on the ZapLogger.

func Print

func Print(args ...interface{})

Print logs a message at level Info on the ZapLogger.

func Printf

func Printf(format string, args ...interface{})

Printf logs a message at level Info on the ZapLogger.

func Println

func Println(args ...interface{})

Println logs a message at level Info on the ZapLogger.

func Warn

func Warn(args ...interface{})

Warn logs a message at level Warn on the ZapLogger.

func Warnf

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

Warnf logs a message at level Warn on the ZapLogger.

func Warning

func Warning(args ...interface{})

Warning logs a message at level Warn on the ZapLogger.

func Warningf

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

Warningf logs a message at level Warn on the ZapLogger.

Types

type Logger

type Logger struct {
	Log *zap.Logger
}

Logger zap log

var Default *Logger

Default default log

func InitZapLogger added in v0.2.6

func InitZapLogger(log *zap.Logger) *Logger

InitZapLogger initial

func New

func New(fh string, flag bool) *Logger

New

func NewDevelopment

func NewDevelopment() *Logger

NewDevelopment new log for development

func NewProduction

func NewProduction() *Logger

NewProduction new log for production

func NewZapLogger

func NewZapLogger() *Logger

NewZapLogger return ZapLogger with caller field

func (*Logger) Debug

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

Debug logs a message at level Debug on the ZapLogger.

func (*Logger) Debugf

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

Debugf logs a message at level Debug on the ZapLogger.

func (*Logger) Error

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

Error logs a message at level Error on the ZapLogger.

func (*Logger) Errorf

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

Errorf logs a message at level Warn on the ZapLogger.

func (*Logger) Fatal

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

Fatal logs a message at level Fatal on the ZapLogger.

func (*Logger) Fatalf

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

Fatalf logs a message at level Warn on the ZapLogger.

func (*Logger) Info

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

Info logs a message at level Info on the ZapLogger.

func (*Logger) Infof

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

Infof logs a message at level Info on the ZapLogger.

func (*Logger) Panic

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

Panic logs a message at level Painc on the ZapLogger.

func (*Logger) Panicf

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

Panicf logs a message at level Warn on the ZapLogger.

func (*Logger) Print

func (l *Logger) Print(args ...interface{})

Print logs a message at level Info on the ZapLogger.

func (*Logger) Printf

func (l *Logger) Printf(format string, args ...interface{})

Printf logs a message at level Info on the ZapLogger.

func (*Logger) Warn

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

Warn logs a message at level Warn on the ZapLogger.

func (*Logger) Warnf

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

Warnf logs a message at level Warn on the ZapLogger.

func (*Logger) Warning added in v0.3.0

func (l *Logger) Warning(args ...interface{})

Warning logs a message at level Warn on the ZapLogger.

func (*Logger) Warningf added in v0.3.0

func (l *Logger) Warningf(template string, args ...interface{})

Warningf logs a message at level Warn on the ZapLogger.

func (*Logger) With

func (l *Logger) With(key string, value interface{}) *Logger

With return a log with an extra field.

func (*Logger) WithField

func (l *Logger) WithField(key string, value interface{}) *Logger

WithField return a log with an extra field.

func (*Logger) WithFields

func (l *Logger) WithFields(fields map[string]interface{}) *Logger

WithFields return a log with extra fields.

type ZapLogger

type ZapLogger = Logger

ZapLogger alias

Directories

Path Synopsis
Package ginzap provides a logging middleware to get https://github.com/uber-go/zap as logging library for https://github.com/gin-gonic/gin.
Package ginzap provides a logging middleware to get https://github.com/uber-go/zap as logging library for https://github.com/gin-gonic/gin.
Package zapgrpc2 provides a logger that is compatible with grpclog.
Package zapgrpc2 provides a logger that is compatible with grpclog.

Jump to

Keyboard shortcuts

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