logger

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileLogger added in v0.7.2

func FileLogger(outputDir, filename string) (*slog.Logger, func(), error)

FileLogger 返回写入 outputDir/logs/filename 的独立 logger 与清理函数, 供需要独立日志文件的子系统(如导入流程)使用。打开失败回退默认 logger 不中断业务, 但错误必须返回给调用方向用户呈现——否则 UI 指引用户去看一个并不存在的日志文件。

func Setup

func Setup(w io.Writer, level slog.Level)

Setup 初始化 slog 默认 logger。 w 为日志输出目标,level 为最低日志级别。

func SetupFile

func SetupFile(outputDir, filename string, alsoStderr bool) (func(), error)

SetupFile 初始化默认 logger 到文件,返回清理函数。 alsoStderr=true 时同时输出到 stderr。 日志目录或文件无法打开时返回错误,调用方必须显式处理;禁止切到 io.Discard 后继续运行,否则恰好在最需要排障时丢失全部运行日志。

Types

This section is empty.

Jump to

Keyboard shortcuts

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