logging

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package logging 统一构造 slog 日志器。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(w io.Writer, opts Options) *slog.Logger

New 按 opts 构造日志器,写入 w。 无法识别的取值回退到 info / text,而不是报错——日志本身不该成为启动失败的原因。

func ParseLevel

func ParseLevel(level string) slog.Level

ParseLevel 把级别字符串转成 slog.Level,无法识别时回退 info。

Types

type Options

type Options struct {
	// Level 取值 debug / info / warn / error,大小写不敏感。
	Level string
	// Format 取值 text / json,大小写不敏感。
	Format string
}

Options 是日志器构造参数。

Jump to

Keyboard shortcuts

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