lib

package
v0.0.0-...-eab5816 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package Timer is timed contain, base on Time wheel algorithm.

the library of logging, can use global method(as Info, Debug, Warn, Error, Panic, Fatal) everywhere, also define a struct of Log implement the interface of Logger

the library of text color, set the color to text tag of message.

Index

Constants

View Source
const (
	// InfoLevel the default level of logging.
	InfoLevel = iota + 1
	// DebugLevel the debug level of logging, usually use in development.
	DebugLevel
	// WarnLevel log the type of warn message.
	WarnLevel
	// ErrorLevel log the type of error message.
	ErrorLevel
	// PanicLevel log a message and panic.
	PanicLevel
	// FatalLevel log a message and call os.Exit(1).
	FatalLevel
)
View Source
const (
	TextBlack = iota + 30
	TextRed
	TextGreen
	TextYellow
	TextBlue
	TextMagenta
	TextCyan
	TextWhite
)

number value constant of color.

Variables

This section is empty.

Functions

func Black

func Black(str string) string

Black color of black.

func Blue

func Blue(str string) string

Blue color of Blue.

func Cyan

func Cyan(str string) string

Cyan color of Cyan.

func Debug

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

Debug log the type of Debug message.

func Error

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

Error log the type of error message.

func Fatal

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

Fatal log a message and call os.Exit(1).

func Green

func Green(str string) string

Green color of Green.

func Info

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

Info log the type of info message.

func Magenta

func Magenta(str string) string

Magenta color of Magenta.

func Panic

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

Panic log a message and call panic.

func Red

func Red(str string) string

Red color of Red, usually use in the type of error, fatal message.

func UcFirst

func UcFirst(str string) string

UcFirst ToUpper the first char of strings.

func Warn

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

Warn log the type of warn message.

func White

func White(str string) string

White color of White.

func Yellow

func Yellow(str string) string

Yellow color of Yellow.

Types

type BytePool

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

BytePool response the slice byte pool.

func NewBytesPool

func NewBytesPool(size int) *BytePool

NewBytesPool return a bytes pool instance.

func (*BytePool) Get

func (bp *BytePool) Get() *byteBuffer

Get get a byteBuffer from pool.

func (*BytePool) Put

func (bp *BytePool) Put(bf *byteBuffer)

Put put byteBuffer back to pool.

type Log

type Log struct {
}

Log struct of Log

func (*Log) Debug

func (l *Log) Debug(format string, a ...interface{})

func (*Log) Error

func (l *Log) Error(format string, a ...interface{})

func (*Log) Fatal

func (l *Log) Fatal(format string, a ...interface{})

func (*Log) Info

func (l *Log) Info(format string, a ...interface{})

func (*Log) Panic

func (l *Log) Panic(format string, a ...interface{})

func (*Log) Warn

func (l *Log) Warn(format string, a ...interface{})

type Logger

type Logger interface {
	// Info log the type of info message.
	Info(format string, a ...interface{})
	// Debug log the type of Debug message.
	Debug(format string, a ...interface{})
	// Warn log the type of warn message.
	Warn(format string, a ...interface{})
	// Error log the type of error message.
	Error(format string, a ...interface{})
	// Panic log a message and call panic.
	Panic(format string, a ...interface{})
	// Fatal log a message and call os.Exit(1).
	Fatal(format string, a ...interface{})
}

type TaskID

type TaskID int

TaskID represent a task ID which used to delete.

type Timer

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

Timer timed container.

func NewTimer

func NewTimer(slotNumber int, si time.Duration) *Timer

NewTimer return a timer contain.

func (*Timer) Add

func (t *Timer) Add(timeInterval time.Duration, fn func(v ...interface{}), args interface{}, persistent bool) TaskID

Add add a timed task.

func (*Timer) Del

func (t *Timer) Del(id TaskID) bool

Del delete a timed task.

func (*Timer) Start

func (t *Timer) Start()

Start start to run.

func (*Timer) Stop

func (t *Timer) Stop()

Stop stopChannel task.

Jump to

Keyboard shortcuts

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