Token导航 LogoToken导航TokenDH.com
前端设计执行命令github未标认证来源可访问许可证需确认审计通过

setting-up-logging设置日志记录

Agent Skill

setting-up-logging 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

282

周安装

12

GitHub Stars

公开资料未说明

下载量

99
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:setting-up-logging(设置日志记录)
来源仓库:https://github.com/quick-brown-foxxx/coding_rules_python
仓库路径:skills/setting-up-logging
安装命令:
npx skills add https://github.com/quick-brown-foxxx/coding_rules_python --skill setting-up-logging
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/quick-brown-foxxx/coding_rules_python --skill setting-up-logging

简介

setting-up-logging 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中围绕仓库状态、代码变更或协作事项进行整理时使用。

  • 它支持按来源仓库、安装命令和原始 README 核验具体用法,适用于开发协作与代码管理场景。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装,需确认权限范围和维护状态后再部署。
  • 安装前建议检查是否会触发联网、命令执行或文件读写,避免误操作影响系统安全。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Setting Up Logging

Rotating file logging, colored stdout logging, and colored non-log output. Uses colorlog for prefix-only coloring (log prefix is colored, message text stays default).

Copy reusable code from coding_rules_python/reusable/logging/.


Key Principle

File logging is always on — it's the durable record for post-mortem debugging. Stdout is lost on terminal close; file logs survive.

Stdout logging is for modes where no human reads stdout directly. When you launch a GUI app from terminal or run a server in a container, stdout logs are useful — they show real-time output during development and serve as container log transport (Docker/systemd capture stdout).

CLI tools must NOT use stdout logging — stdout is the user interface. Log lines mixed into stdout corrupt the output (imagine mytool | grep something with log lines). Use write_info/write_error for user-facing messages instead.

ModeFile logStdout logNon-log colored output
CLI toolAlwaysNeverwrite_info, write_error for user messages
GUI appAlwaysYes (dev convenience from terminal)No (no terminal)
Server (FastAPI)AlwaysYes (container log transport)No

When to Use

  • Every appsetup_file_logging() in your entrypoint
  • GUI apps / servers — also setup_stdout_logging() (stdout is not the user interface)
  • CLI toolswrite_info/write_error for user-facing messages (NOT stdout logging)
  • Suppressing noisy loggersconfigure_logger_level("httpx", logging.WARNING)

Typical Patterns

CLI tool — file logging + colored user output

import logging
from pathlib import Path
from shared.logging import setup_file_logging, configure_logger_level, write_info, write_error

# File logs always on
setup_file_logging(
    log_dir=Path("~/.local/state/myapp/logs").expanduser(),
    app_name="myapp",
)
configure_logger_level("httpx", logging.WARNING)

# User-facing output via write_info/write_error (NOT stdout logging)
write_info("Processing 42 items...")
write_error("Connection failed")

GUI app / server — file logging + stdout logging

import logging
from pathlib import Path
from shared.logging import setup_file_logging, setup_stdout_logging, configure_logger_level

# File logs always on
setup_file_logging(
    log_dir=Path("~/.local/state/myapp/logs").expanduser(),
    app_name="myapp",
)
# Stdout logs for dev convenience (visible when launched from terminal / in containers)
setup_stdout_logging(level=logging.INFO)
configure_logger_level("httpx", logging.WARNING)

Stdout output format (colored):

<green>2025-12-19 00:01:35 [INFO] myapp.core:</green> Processing 42 items
<yellow>2025-12-19 00:01:36 [WARNING] myapp.core:</yellow> Slow response from API

File output format (plain):

2025-12-19 00:01:35 [INFO] myapp.core: Processing 42 items
2025-12-19 00:01:36 [WARNING] myapp.core: Slow response from API

Color scheme (stdout only):

LevelColor
DEBUGCyan
INFOGreen
WARNINGYellow
ERRORRed
CRITICALRed on white

Non-Log Colored Output

For CLI tools — colored messages that are NOT log entries (status messages, results, prompts). This is how CLI tools communicate with the user instead of stdout logging:

from shared.logging import write_info, write_success, write_warning, write_error

write_info("Starting download...")      # Green → stdout
write_success("Download complete!")     # Green → stdout
write_warning("Large file detected")   # Yellow → stdout
write_error("Failed to connect")       # Red → stderr

Dependencies

[project]
dependencies = [
    "colorlog>=6.10.1",
]

Files to Copy

Copy the entire coding_rules_python/reusable/logging/ directory into your project's shared/logging/:

  • __init__.py — public API re-exports
  • logger_setup.pysetup_stdout_logging(), setup_file_logging(), configure_logger_level()
  • non_log_stdout_output.pywrite_info(), write_success(), write_warning(), write_error()
  • README.md — references this skill

Update import paths after copying (e.g., from shared.logging import...).


QML Log Routing (PySide6)

QML console.info/warn/error can be routed through Python's logging module via a custom Qt message handler. This integrates QML output with your file and stdout logging setup. The handler logs under the qt.qml logger name, so you can filter it independently.

See the building-qt-apps skill for the full handler implementation and the console.log() gotcha (it's silently dropped by Qt).


API Reference

setup_file_logging(log_dir, app_name="app", level=DEBUG, max_bytes=5MB, backup_count=3)

Add RotatingFileHandler to root logger. Creates <log_dir>/<app_name>.log. Always use this — every app needs durable file logs.

setup_stdout_logging(level=logging.INFO)

Add colored StreamHandler to root logger. For GUI apps and servers where stdout is not the user interface. Do NOT use for CLI tools.

configure_logger_level(logger_name, level, propagate=True)

Set a specific logger's level. Use to suppress verbose third-party loggers.

write_info(message) / write_success(message)

Green text to stdout.

write_warning(message)

Yellow text to stdout.

write_error(message)

Red text to stderr.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.77%
按下载量换算35

Claude

30.68%
按下载量换算30

Cursor

18.66%
按下载量换算18

Gemini CLI

8.25%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/quick-brown-foxxx/coding_rules_python --skill setting-up-logging 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills