logjson

package
v0.0.0-...-501ba56 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSyncWriter

func NewSyncWriter(writer io.Writer) io.Writer

NewSyncWriter 返回写互斥的 io.Writer

Types

type BytesBufferPool

type BytesBufferPool interface {
	Get() *bytes.Buffer
	Put(buffer *bytes.Buffer)
}

func NewBytesBufferPool

func NewBytesBufferPool(initialSize, maximumSize int) BytesBufferPool

NewBytesBufferPool 创建并返回 BytesBufferPool

type Entry

type Entry struct {
	Message string         `json:"msg"`
	Time    string         `json:"time,omitempty"`
	Caller  *logsdk.Frame  `json:"caller,omitempty"`
	Stack   []logsdk.Frame `json:"stack,omitempty"`
	Fields  []logsdk.KV    `json:"fields,omitempty"`
	Level   logsdk.Level   `json:"level"`
}

Entry 被用来 JSON 序列化

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option 配置日志处理对象

func WithBufferPool

func WithBufferPool(pool BytesBufferPool) Option

WithBufferPool 配置缓冲池

func WithDisableHTMLEscape

func WithDisableHTMLEscape(disable bool) Option

WithDisableHTMLEscape 配置禁止 HTML 转义

func WithDisableTime

func WithDisableTime(disable bool) Option

WithDisableTime 配置仅用时间输出

func WithOutput

func WithOutput(w io.Writer) Option

WithOutput 配置输出

func WithPrettyPrint

func WithPrettyPrint(pretty bool) Option

WithPrettyPrint 配置 JSON 多行缩进输出

func WithTimeFormat

func WithTimeFormat(format string) Option

WithTimeFormat 配置时间格式

type Processor

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

Processor 日志处理对象, 把日志处理成 JSON.

func New

func New(opts ...Option) *Processor

New 返回日志处理对象, 返回的对象是 logsdk.EntryProcessor.

func (*Processor) Process

func (processor *Processor) Process(_ context.Context, entry logsdk.ReadonlyEntry)

Process 处理日志

Jump to

Keyboard shortcuts

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