zlog

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2019 License: MIT Imports: 3 Imported by: 4

README

logo

Build Status Coverage Status GoDoc Go Report Card license

zlog

Just Log Basic On zerolog

Install

$ go get -u github.com/haozibi/zlog

Demo

package main

import (
	"os"

	"github.com/haozibi/zlog"
)

func init() {

	zlog.NewBasicLog(os.Stdout,WithNoColor(true), WithDebug(true))
	// zlog.NewJSONLog(os.Stdout)
}

func main() {
	zlog.ZInfo().
		Int("z", 100-1).
		Msg("just do it")

	zlog.ZDebug().
		Float64("f", 3.1415926).
		Msgf("hello %s", "zlog")
}

Documentation

Overview

Example
NewBasicLog(os.Stdout, WithNoColor(true), WithDebug(true), WithTimeFormat("2006"))
// zlog.NewJSONLog(os.Stdout)

ZInfo().
	Int("z", 100-1).
	Msg("just do it")

ZDebug().
	Float64("f", 3.1415926).
	Msgf("hello %s", "zlog")
Output:
2019 INF example_test.go:11 > just do it z=99
2019 DBG example_test.go:15 > hello zlog f=3.1415926

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// TimeFieldFormat time format
	TimeFieldFormat = time.RFC3339

	// TimeFormatUnixNano time format
	TimeFormatUnixNano = "2006-01-02 15:04:05.999999999"

	// NoColor if set color
	NoColor = false
)

Functions

func Debugf

func Debugf(format string, v ...interface{})

Debugf debug format

func NewBasicLog

func NewBasicLog(w io.Writer, opts ...LogOpt)

NewBasicLog new basic log

func NewJSONLog

func NewJSONLog(w io.Writer, opts ...LogOpt)

NewJSONLog new log by json format

func ZDebug

func ZDebug() *zerolog.Event

ZDebug debug log

func ZError

func ZError() *zerolog.Event

ZError error log

func ZFatal

func ZFatal() *zerolog.Event

ZFatal fatal log

func ZInfo

func ZInfo() *zerolog.Event

ZInfo info log

func ZWarn

func ZWarn() *zerolog.Event

ZWarn warn log

Types

type LogOpt added in v0.1.3

type LogOpt func(o *option)

LogOpt log option

func WithDebug added in v0.1.3

func WithDebug(debug bool) LogOpt

WithDebug set if debug,debug output line num

func WithDeep added in v0.1.3

func WithDeep(n int) LogOpt

WithDeep set line deep,default eq 2

func WithNoColor added in v0.1.3

func WithNoColor(nocolor bool) LogOpt

WithNoColor set if has color

func WithTimeFormat added in v0.1.3

func WithTimeFormat(format string) LogOpt

WithTimeFormat set time format when basic format

Jump to

Keyboard shortcuts

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