log

package module
v0.0.0-...-392693e Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: BSD-3-Clause Imports: 11 Imported by: 0

README

log

How to use

  1. use Default
  log.Default() // you can see the default setting at config.go
  log.Info("info")
  1. use file path
  log.InitByConfigFile("./log.conf") // you can see the example at example 
  log.Info("info")
  1. use json
  log.InitByConfigJson(string(log.GetDefaultLogConfig()))
  log.Info("info")

benchstat

system: windows 7 x64 sp1

cpu(s): 8

model name: Intel(R) Core(TM) i7-3610QM CPU @ 2.30GHz

memery: 8G

TextPositiveWithConsole
test ops ns/op bytes/op allocs/op
BenchmarkLogTextPositive 30000 46702 ns/op 4016 B/op 78 allocs/op
BenchmarkLogTextPositive-2 50000 24721 ns/op 4016 B/op 78 allocs/op
BenchmarkLogTextPositive-4 100000 15950 ns/op 4017 B/op 78 allocs/op
BenchmarkLogTextPositive-8 200000 11295 ns/op 4019 B/op 78 allocs/op
TextPositiveWithoutConsole
test ops ns/op bytes/op allocs/op
BenchmarkLogTextPositive 100000 18831 ns/op 2480 B/op 48 allocs/op
BenchmarkLogTextPositive-2 200000 10010 ns/op 2480 B/op 48 allocs/op
BenchmarkLogTextPositive-4 200000 6840 ns/op 2481 B/op 48 allocs/op
BenchmarkLogTextPositive-8 200000 7905 ns/op 2482 B/op 48 allocs/op

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Critical

func Critical(a ...interface{})

log critical level

func Criticalf

func Criticalf(format string, a ...interface{})

log critical format

func Debug

func Debug(a ...interface{})

log debug level

func Debugf

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

log debug format

func Default

func Default()

func Error

func Error(a ...interface{})

log error level

func Errorf

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

log error format

func Fatal

func Fatal(a ...interface{})

log critical level

func Fatalf

func Fatalf(format string, a ...interface{})

log critical format

func GetDefaultLogConfig

func GetDefaultLogConfig() []byte

func Info

func Info(a ...interface{})

log info level

func Infof

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

log info format

func InitByConfigFile

func InitByConfigFile(filePath string)

func InitByConfigJson

func InitByConfigJson(configJson string)

func InitByConfigStruct

func InitByConfigStruct(conf *LogConfig)

func Notice

func Notice(a ...interface{})

log notice level

func Noticef

func Noticef(format string, a ...interface{})

log notice format

func Warn

func Warn(a ...interface{})

log warning level

func Warnf

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

log warning format

Types

type LogConfig

type LogConfig struct {
	Level         string
	FileName      string
	LevelFileName map[string]string
	HasConsole    bool
	Color         bool
	Json          bool
	MaxSize       int
	MaxAge        int
	DateSlice     string
	Format        string
}

func LoadLogConfigFile

func LoadLogConfigFile(configJsonFilePath string) (*LogConfig, error)

func LoadLogConfigJson

func LoadLogConfigJson(configJson []byte) (*LogConfig, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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