logs

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: MIT Imports: 10 Imported by: 6

README

log

golang log package

install

go get -u dukangxu.com/git/dukangxu/logs

example

Debug("Debug", "log")
Info("Info", "log")
Error("Error", "log")
Warn("Warn", "log")
Debugf("%s-%s\n", "Debugf", "log")
Infof("%s-%s\n", "Infof", "log")
Errorf("%s-%s\n", "Errorf", "log")
Warnf("%s-%s\n", "Warnf", "log")
Fatal("Fatal")
Fatalf("%s-%s\n", "Fatalf", "log")

Documentation

Overview

Package logs implements a simple library for log.

Index

Constants

View Source
const (
	// KB size 1024 * byte
	KB = 1024
	// MB size 1024 * KB
	MB = KB * 1024
	// MinSizeInterval min size of size rolling
	MinSizeInterval = 10 * KB //10KB
	// Second time 1
	Second = 1
	// Minute time 60 * Second
	Minute = 60 * Second
	// MinTimeInterval min time of time rolling
	MinTimeInterval = 10 * Second //10Second
)
View Source
const (
	// DebugFlag debug level flag
	DebugFlag = "debug"
	// InfoFlag info level flag
	InfoFlag = "info"
	// WarnFlag warn level flag
	WarnFlag = "warn"
	// ErrorFlag error level flag
	ErrorFlag = "error"
	// TimeFlag time rolling mode flag
	TimeFlag = "time"
	// SizeFlag size rolling mode flag
	SizeFlag = "size"
)

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

Debug print log at debug level

func Debugf

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

Debugf print log at debug level with format

func Error

func Error(args ...interface{})

Error print log at error level

func Errorf

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

Errorf print log at error level with format

func Fatal

func Fatal(args ...interface{})

Fatal print log and exit

func Fatalf

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

Fatalf print log with format and exit

func Info

func Info(args ...interface{})

Info print log at info level

func Infof

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

Infof print log at info level with format

func Warn

func Warn(args ...interface{})

Warn print log at warn level

func Warnf

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

Warnf print log at warn level with format

Types

type Level

type Level int

Level log level type

const (
	// DebugLevel log level 0
	DebugLevel Level = iota
	// InfoLevel log level 1
	InfoLevel
	// WarnLevel log level 2
	WarnLevel
	// ErrorLevel log level 3
	ErrorLevel
	// LastLevel level boundary
	LastLevel
)

type Logger

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

Logger log struct

func Log

func Log() *Logger

Log return Logger pointer

func (*Logger) Level

func (l *Logger) Level(flag string) *Logger

Level set log level

func (*Logger) LogFile

func (l *Logger) LogFile(logf string) *Logger

LogFile set log file

func (*Logger) Rolling

func (l *Logger) Rolling(flag string, interval int64) *Logger

Rolling set log rolling flag: time, size, empty(not rolling)

type Rolling

type Rolling int

Rolling log rolling type

const (

	// TimeRolling rolling mode
	TimeRolling Rolling
	// SizeRolling rolling mode
	SizeRolling
)

Jump to

Keyboard shortcuts

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