logging

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: GPL-3.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package logging 为所有 sctl 子命令初始化统一的 zap 日志。

关键约束:日志绝不写 stdout —— `sctl mcp` 以 stdout 承载 MCP 协议帧,CLI 动词以 stdout 输出 `-o json` / `-o source` 结果,任何日志混入都会破坏它们。cago 的 component.Core() 默认 把日志写 stdout,因此 sctl 改由本包用 logger.New + NewFileCore 构建 logger 并 logger.SetLogger 注入 cago,后续代码照常用 logger.Ctx(ctx)。

出口:持久文件日志(<dataDir>/logs/sctl.log 收 level+,sctl.err.log 只收 error+) 外加 stderr console core —— sctl serve/connect 是前台命令,stderr 让用户实时看到日志, 且 stderr 与 stdout 协议/JSON 输出互不干扰。服务管理器托管的 serve 不要 stderr core: launchd 把 stderr 写进一个不滚动的文件,再写一份会无限增长。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Setup

func Setup(level string, toStderr bool) *zap.Logger

Setup 构建并注入全局 logger。level 取 debug/info/warn/error;toStderr 为 false 时只写文件。 文件日志目录不可写时静默降级为仅 stderr(不因日志目录问题阻断命令,也不丢日志)。 返回构建出的 logger 供直接使用。

Types

This section is empty.

Jump to

Keyboard shortcuts

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