common

package
v5.1.14 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBucketIsFull = fmt.Errorf("bucket is fully")
)

Functions

func InternalFatal

func InternalFatal(text string, args ...interface{})

InternalFatal 内部/Fatal.

func InternalInfo

func InternalInfo(text string, args ...interface{})

InternalInfo 内部/Info.

Types

type Bucket

type Bucket interface {
	// Add
	// 添加元素.
	Add(item interface{}) (total int, err error)

	// Count
	// 桶元素量.
	Count() int

	// IsEmpty
	// 是否为空.
	IsEmpty() bool

	// Pop
	// 取出1个元素.
	Pop() (item interface{}, exists bool)

	// Popn
	// 取出N个元素.
	//
	// 参数 limit 为需取出元素量. 返回 items 为已取出的元素列表, total 为取出前桶
	// 内元素总量, count 为实际取出元素量.
	Popn(limit int) (items []interface{}, total, count int)

	// SetCapacity
	// 设置容量.
	SetCapacity(n int) Bucket
}

Bucket 数据桶.

func NewBucket

func NewBucket(capacity int) Bucket

NewBucket 创建数据桶.

type Level

type Level string

Level 日志级别.

const (
	Off   Level = "OFF"
	Debug Level = "DEBUG"
	Error Level = "ERROR"
	Fatal Level = "FATAL"
	Info  Level = "INFO"
	Warn  Level = "WARN"
)

func (Level) Int

func (o Level) Int() int

Int 转整型.

func (Level) String

func (o Level) String() string

String 转字符串.

func (Level) Upper

func (o Level) Upper() Level

Upper 转大写.

Level("debug").Upper() <-> Level("DEBUG")

type Stack

type Stack struct {
	Items []StackItem
}

Stack 栈结构.

func Backstack

func Backstack() Stack

Backstack 解析堆栈.

type StackItem

type StackItem struct {
	// 是否内部.
	// true 表示元素是 fuyibing/log 包中的文件.
	Internal bool

	// 函数名称.
	// 例如: main.main()
	Call string

	// 文件路径.
	// 例如: /home/app/github.com/fuyibing/log/v5/field.go
	File string

	// 触发行号.
	Line int
}

StackItem 栈元素.

Jump to

Keyboard shortcuts

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