dlog

package module
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2018 License: MIT Imports: 9 Imported by: 14

README

go-dlog Doc

📟 conditional logging for Golang libraries & applications

screenshot

installation

go get gopkg.in/ddo/go-dlog.v2

usage

logger := dlog.New("logger", nil)

logger.Debug("some log")
logger.Info("some log")
logger.Warn("some log")
logger.Error("some log")
DLOG=* go run example.go

env

set DLOG environment(case-insensitive) to

  • DEBUG or * to enable #Debug and above
  • INFO to enable #Info, #Done, #Fail and above
  • WARN to enable #Warn and above
  • ERROR to enable #Error

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dlog

type Dlog struct {
	Debug            handler
	Info, Done, Fail handler
	Warn             handler
	Error            handler
	// contains filtered or unexported fields
}

Dlog .

func New

func New(name string, opt *Option) (_dlog *Dlog)

New .

type Log

type Log struct {
	Rank string `json:"rank"`

	Name   string `json:"name"`
	Caller string `json:"caller"` // function name

	Timestamp time.Time     `json:"timestamp"`
	Delta     time.Duration `json:"delta"`

	Data []interface{} `json:"data"`
}

Log is a single log object

func NewLog

func NewLog(rank, name string, now time.Time, delta time.Duration, arg ...interface{}) *Log

NewLog .

type Option

type Option struct {
	Writer io.Writer
	Hook   chan<- *Log
	Type   string
}

Option .

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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