logger

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: BSD-3-Clause Imports: 10 Imported by: 28

README

go-logger

Coverage Status Release Go Report Card Build Status

How to use it

package main

import (
	"os"
	"time"

	"github.com/deweppro/go-logger"
)

func main() {
	logger.SetOutput(os.Stdout)

	logger.Infof("sync %d", 1)
	logger.Warnf("sync %d", 2)
	logger.Errorf("sync %d", 3)
	logger.Debugf("sync %d", 4)

	logger.Close()
}

Example log output:

{"time":1602721013,"type":"INF","data":"sync 1"}
{"time":1602721013,"type":"WRN","data":"sync 2"}
{"time":1602721013,"type":"ERR","data":"sync 3"}
{"time":1602721013,"type":"DBG","data":"sync 4"}
...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close added in v1.2.0

func Close()

Close waiting for all messages to finish recording

func Debugf added in v1.1.0

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

Debugf debug message

func Errorf added in v1.1.0

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

Errorf error message

func Infof added in v1.1.0

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

Infof info message

func SetOutput added in v1.1.0

func SetOutput(out io.Writer)

SetOutput change writer

func Warnf added in v1.1.0

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

Warnf warning message

Types

type Log added in v1.2.0

type Log struct {
	// contains filtered or unexported fields
}

Log base model

func Default added in v1.1.0

func Default() *Log

Default logger

func New added in v1.1.0

func New() *Log

New init new logger

func (*Log) Close added in v1.2.0

func (l *Log) Close()

Close waiting for all messages to finish recording

func (*Log) Debugf added in v1.2.0

func (l *Log) Debugf(format string, args ...interface{})

Debugf debug message

func (*Log) Errorf added in v1.2.0

func (l *Log) Errorf(format string, args ...interface{})

Errorf error message

func (*Log) Infof added in v1.2.0

func (l *Log) Infof(format string, args ...interface{})

Infof info message

func (*Log) SetOutput added in v1.2.0

func (l *Log) SetOutput(out io.Writer)

SetOutput change writer

func (*Log) Warnf added in v1.2.0

func (l *Log) Warnf(format string, args ...interface{})

Warnf warning message

type Logger

type Logger interface {
	SetOutput(out io.Writer)
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Debugf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
}

Logger base interface

type Message added in v1.2.0

type Message struct {
	Time int64  `json:"time"`
	Type string `json:"type"`
	Data string `json:"data"`
}

Message model

func (Message) MarshalEasyJSON added in v1.2.0

func (v Message) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Message) MarshalJSON added in v1.2.0

func (v Message) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Message) UnmarshalEasyJSON added in v1.2.0

func (v *Message) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Message) UnmarshalJSON added in v1.2.0

func (v *Message) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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