logger

package
v0.0.0-...-ae84a6d Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddListener

func AddListener(l Listener)

增加一個監聽器用於獲取 輸出到 stdout 的日誌

func Init

func Init(basePath string, options *cnf.Logger)

初始化日誌

func RemoveListener

func RemoveListener(l Listener)

移除監聽器

Types

type Listener

type Listener interface {
	OnChanged([]byte)
}

這是一個監聽器,當有日誌輸出到 stdout 時它會被回調

type SnapshotListener

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

這是一個 stdout 的日誌監聽器,如果你不即使讀取它,它將只保留最後的兩個日誌

func NewSnapshotListener

func NewSnapshotListener(done <-chan struct{}) *SnapshotListener

創建監聽器

func (*SnapshotListener) Channel

func (l *SnapshotListener) Channel() <-chan []byte

讀取收到的日誌

func (*SnapshotListener) OnChanged

func (l *SnapshotListener) OnChanged(b []byte)

首先 Listener 接口

type Wrap

type Wrap struct {

	// zap 日誌
	*zap.Logger
	// contains filtered or unexported fields
}

對 zap.Logger 的包裝

var Logger Wrap

日誌單例

func New

func New(options *cnf.Logger, zapOptions ...zap.Option) *Wrap

func (*Wrap) Attach

func (l *Wrap) Attach(src *Wrap)

func (*Wrap) ConsoleLevel

func (l *Wrap) ConsoleLevel() zap.AtomicLevel

func (*Wrap) Detach

func (l *Wrap) Detach()

Detach Logger

func (*Wrap) FileLevel

func (l *Wrap) FileLevel() zap.AtomicLevel

Jump to

Keyboard shortcuts

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