lg

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2019 License: MIT Imports: 8 Imported by: 0

README

lg

License

Project logger packaging for github.com/uber-go/zap

Getting Started

Suitable for project log in the container

Installation

go get -u github.com/qclaogui/lg

Usage Run in Playground

package main

import (
	"github.com/qclaogui/lg"
)

func main() {
	//lg.TimeFormat = time.RFC3339Nano

	// lvl - global log level: Debug(-1), Info(0), Warn(1), Error(2), DPanic(3), Panic(4), Fatal(5)
	_ = lg.Init(-1, "demo-project")

	lg.APPLog.Info("Happy Goding!")
}
// Output: {"level":"info","ts":1564834577.710078,"msg":"Happy Goding!","info":{"project":"demo-project","hostname":"qclaogui.local"}}

Versioning

Using SemVer for versioning. For the versions available, see the tags on this repository.

License

This project is licensed under the MIT License - see the LICENSE file for details

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// APPLog is global logger
	APPLog *zap.Logger

	// TimeFormat is custom Time format
	// example: "2006-01-02T15:04:05.999999999Z07:00"
	// 推荐不要设置, 使用默认时间戳
	TimeFormat string
)

Functions

func Init

func Init(lvl int, project string) (err error)

Init initializes log by input parameters lvl - global log level: Debug(-1), Info(0), Warn(1), Error(2), DPanic(3), Panic(4), Fatal(5) timeFormat - custom time format for logger of empty string to use default

func InitOnlyKafka added in v0.2.0

func InitOnlyKafka(lvl int, project, kafkaTopic, brokers string) (err error)

Init initializes log by input parameters lvl - global log level: Debug(-1), Info(0), Warn(1), Error(2), DPanic(3), Panic(4), Fatal(5) timeFormat - custom time format for logger of empty string to use default

func InitWithKafka added in v0.2.0

func InitWithKafka(lvl int, project, kafkaTopic, brokers string) (err error)

Init initializes log by input parameters lvl - global log level: Debug(-1), Info(0), Warn(1), Error(2), DPanic(3), Panic(4), Fatal(5) timeFormat - custom time format for logger of empty string to use default

Types

This section is empty.

Jump to

Keyboard shortcuts

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