x-log

Standardize structured logging in Go services with slog conventions.

2|Updated Apr 12, 2026
One-click install
npx skills add https://github.com/pure-golang/level85 --skill x-log
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: x-log
Source: https://github.com/pure-golang/level85/tree/main/.agents/skills/x-log
Command: npx skills add https://github.com/pure-golang/level85 --skill x-log

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill solves inconsistent, hard-to-debug logging practices by enforcing a single structured logging policy for Go services so logs carry the right module identity and correct context-aware logger usage.

Core Features & Use Cases

  • Canonical logging ownership: Defines how to place and configure *slog.Logger fields, including consistent module naming.
  • Context-aware handler logging: Ensures HTTP/gRPC handlers use logger.FromContext(ctx) so request fields are preserved.
  • Safe, consistent log semantics: Standardizes log levels, English messages, snake_case keys, and error attribute naming using err.

Quick Start

When adding logging to a service, adapter, repository, client, resolver, or handler, apply the x-log policy: store a *slog.Logger with a correctly named module in the component and use logger.FromContext(ctx) inside handlers.

Frequently Asked Questions about x-log

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I standardize structured logging across Go services?

Structured logging in Go services requires a *slog.Logger field with a consistent module name in components, while HTTP and gRPC handlers must use logger.FromContext(ctx) to preserve request context fields.

How does context-aware logging work in Go handlers?

Context-aware logging in Go handlers works by retrieving the logger via logger.FromContext(ctx), ensuring that request-scoped fields and tracing data are preserved across the service execution flow.

What are the naming conventions for slog attributes in Go?

The naming conventions for slog attributes require log messages to be in English, attribute keys to use snake_case formatting, and error attributes to be consistently named using the err key.

When do I need to use logger.FromContext in Go gRPC or HTTP handlers?

You need to use logger.FromContext in Go handlers whenever adding or changing logging, ensuring the correct logger source is selected so that request fields and module identity are maintained.

What is the best way to configure slog logger ownership in Go repositories and clients?

The best way to configure slog logger ownership in Go repositories and clients is to store a *slog.Logger field within the component and apply a consistent module naming policy for canonical logging.