Logging

Define structured logging standards for Golang applications using log/slog or uber-go/zap.

51|6|Updated Mar 28, 2019
One-click install
npx skills add https://github.com/Mte90/dotfiles --skill logging-mte90
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Logging
Source: https://github.com/Mte90/dotfiles/tree/main/.config/opencode/skills/golang/logging
Command: npx skills add https://github.com/Mte90/dotfiles --skill logging-mte90

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill establishes best practices for structured logging and observability in Golang applications, ensuring logs are machine-readable, contextual, and actionable.

Core Features & Use Cases

  • Structured Logging: Enforces JSON or structured text formats for logs.
  • Leveled Logging: Supports Debug, Info, Warn, and Error levels.
  • Contextual Information: Promotes the inclusion of correlation IDs like TraceID and RequestID.
  • Use Case: Integrate this Skill into your Golang microservice to automatically log incoming requests with a unique TraceID, making it easy to trace a request's journey across multiple services.

Quick Start

Use the Logging skill to set up structured logging in your Golang application.

Frequently Asked Questions about Logging

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

FAQPage Schema
How do I implement structured logging in a Golang microservice?

Structured logging in Golang uses libraries like log/slog or uber-go/zap to output machine-readable JSON formats. This Skill defines standards for initializing loggers and injecting context, ensuring your microservice produces actionable, leveled logs for effective debugging.

What is the best way to add contextual information like TraceID to Golang logs?

Adding contextual information like TraceID to Golang logs requires injecting correlation IDs during logger initialization. This Skill provides standards for including RequestID and TraceID, making it easy to trace a request's journey across multiple services.

Does this logging standard support both log/slog and uber-go/zap?

Yes, this logging standard supports both log/slog and uber-go/zap for Golang applications. It defines best practices for using these libraries to enforce structured formats and leveled logging across Debug, Info, Warn, and Error levels.

How does structured logging improve observability in Golang applications?

Structured logging improves observability by enforcing machine-readable formats that are easy to parse and monitor. This Skill ensures your Golang logs include contextual data and severity levels, enabling effective debugging and monitoring across distributed systems.

Can I use this Skill to set up leveled logging in my Go application?

Yes, you can use this Skill to set up leveled logging in your Go application. It supports Debug, Info, Warn, and Error levels, ensuring proper logger initialization so you can filter and manage log output effectively.