Categorygithub.com/sinlovgo/zlog
modulepackage
1.1.0
Repository: https://github.com/sinlovgo/zlog.git
Documentation: pkg.go.dev

# README

TravisBuildStatus GoDoc GoReportCard codecov

for what

depends

in go mod project

# before above global settings
# test version info
$ git ls-remote -q http://github.com/sinlovgo/zlog.git

# test depends see full version
$ go list -v -m -versions github.com/sinlovgo/zlog
# or use last version add go.mod by script
$ echo "go mod edit -require=$(go list -m -versions github.com/sinlovgo/zlog.git | awk '{print $1 "@" $NF}')"
$ echo "go mod vendor"

config file

zap:
  AtomicLevel: -1 # DebugLevel:-1 InfoLevel:0 WarnLevel:1 ErrorLevel:2
  FieldsAuto: false # is use auto Fields key set
  Fields:
    Key: key
    Val: val
  Development: true # is open Open file and line number
  Encoding: console # output format, only use console or json, default is console
  rotate:
    Filename: log/zlog.log # Log file path
    MaxSize: 16 # Maximum size of each log file, Unit: M
    MaxBackups: 10 # How many backups are saved in the log file
    MaxAge: 7 # How many days can the file be keep, Unit: day
    Compress: true # need compress
  EncoderConfig:
    TimeKey: time
    LevelKey: level
    NameKey: logger
    CallerKey: caller
    MessageKey: msg
    StacktraceKey: stacktrace

use-code

import (
	"github.com/sinlovgo/zlog"
)
func main() {
    // default config conf/config.yaml
	err := zlog.Init("")
	if err != nil {
		fmt.Printf("zlog init error %v\n", err)
		return
	}
	zlog.Sugared.Debugf("Sugared DEBUG info %s", "message")
	zlog.Sugared.Infof("Sugared INFO info %v", "message")
	zlog.Sugared.Infof("Sugared info num %d", 10)
	zlog.Sugared.Debug("Sugared Debug can not format %v", "debug-info")
}

dev

  • use to replace sinlovgo/zlog to you code

  • and run

make init
  • test code
make test

add main.go file and run

make run

dev

evn

  • golang sdk 1.13+

docker

base docker file can replace

# Packages

No description provided by the author

# Functions

Deprecated Debug uses fmt.Sprint to construct and log a message.
Deprecated Debugf uses fmt.Sprintf to log a templated message.
Deprecated Debugw logs a message with some additional context.
Deprecated DPanic uses fmt.Sprint to construct and log a message.
Deprecated DPanicf uses fmt.Sprintf to log a templated message.
Deprecated DPanicw logs a message with some additional context.
Deprecated Error uses fmt.Sprint to construct and log a message.
Deprecated Errorf uses fmt.Sprintf to log a templated message.
Deprecated Errorw logs a message with some additional context.
Deprecated Fatal uses fmt.Sprint to construct and log a message, then calls os.Exit.
Deprecated Fatalf uses fmt.Sprintf to log a templated message, then calls os.Exit.
Deprecated Fatalw logs a message with some additional context, then calls os.Exit.
Deprecated Info uses fmt.Sprint to construct and log a message.
Deprecated Infof uses fmt.Sprintf to log a templated message.
Deprecated Infow logs a message with some additional context.
init path use type yaml if path is empty read default config path: conf/config.yaml.
read default type is json if path is empty read default config path: conf/config.yaml.
Deprecated Panic uses fmt.Sprint to construct and log a message, then panics.
Deprecated Panicf uses fmt.Sprintf to log a templated message, then panics.
Deprecated Panicw logs a message with some additional context, then panics.
Deprecated Sync flushes any buffered log entries.
Deprecated Warn uses fmt.Sprint to construct and log a message.
Deprecated Warnf uses fmt.Sprintf to log a templated message.
Deprecated Warnw logs a message with some additional context.

# Variables

Logger is the global variable for the object of lager.Logger.
No description provided by the author
No description provided by the author

# Structs

No description provided by the author

# Interfaces

Logger is a interface.