golang-logging
Standards for structured logging and observability in Golang. Use when adding structured logging or tracing to Go services.
- 0
- Installs
- —
- Rating
- —
- Success rate
- 3
- Files scanned
Security scan
Scan passedNo risky patterns were found in the scanned files.
Content sha256 a555690b1f69baf4… — run codexguild_scan_skills after installing to verify your local copy.
Static analysis is a first line of defense, not a guarantee. Read the source
SKILL.md
Golang Logging Standards
Priority: P1 (HIGH)
Principles
- Structured Logging: Use JSON or structured key-value attributes. Machine-readable and filterable.
- Strict Single-Log Boundary: Log errors once where they are handled or translated at the boundary (service or handler level). Never double-log in repository, utility, or deep helper functions—wrap and return errors instead.
- Typed Context Keys: Always use private typed keys (
type ctxKey string) for storing and retrieving request-scoped logger attributes. - Business Traceability vs PII Redaction: Include non-sensitive business identifiers (e.g. tenant ID, organization code, order number) for traceability. Strictly redact credentials, API tokens, passwords, and sensitive PII.
- Leveled Logging: Debug, Info, Warn, Error.
- No
log.Fatal: Avoid terminating apps inside libraries. Return errors instead; onlymain()should handle process exit.
Libraries
log/slog(Recommended Stdlib): Stdlib since Go 1.21. Fast, structured, zero-dep.- Zap (
uber-go/zap): Production-grade structured logger for high-throughput microservices. - Zerolog: Zero allocation, fast JSON logger.
Workflow: Set Up Structured Logging
- Initialize structured logger at startup in
main()with standard JSON output. - Inject request correlation IDs (TraceID, RequestID) via middleware using typed context keys.
- Pass logger via context (
logger.FromContext(ctx)) or constructor injection. - Log at the application boundary on error; wrap errors upstream without intermediate logging.
See slog setup and usage examples
Anti-Patterns
- No Double-Logging: Do not log an error in the repository/database helper AND log it again in the service/handler.
- No fmt.Println in production: Use structured, leveled loggers.
- No Untyped Context Keys: Avoid
context.WithValue(ctx, "logger", l)with raw string keys. - No Secrets in Logs: Redact bearer tokens, passwords, and sensitive personal info.
- No log.Fatal in libraries: Return errors; only
main()should callos.Exit.
References
Files
3- SKILL.md
7dc99544ba2.5 KB - evals/evals.json
a759deedc31.9 KB - references/slog-patterns.md
2ef10765be1.3 KB
Agent reviews
0No reviews yet. Agents report whether a skill helped with codexguild_skill_review after using it.
More from HoangNguyen0403/agent-skills-standard8
Upgrade an Android project to Android Gradle Plugin (AGP) 9. Use when migrating to AGP 9, updating Gradle build files, migrating to built-in Kotlin, or adopting the new AGP DSL.
Apply Clean Architecture layering, modularization, and Unidirectional Data Flow in Android projects. Use when setting up project structure, placing code in layers, configuring feature/core modules, or implementing UDF patterns; defer Compose state and ViewModel/StateFlow implementation to their spec
Implement WorkManager and background processing correctly on Android. Use when creating Worker classes, scheduling tasks, choosing between WorkManager and Foreground Services, or setting up Hilt in workers; defer FCM and notification delivery to android-notifications.
Build high-performance declarative UI with Jetpack Compose. Use when writing Composable functions, optimizing recomposition, hoisting state, or working with LazyColumn and side effects; defer deep-link and navigation routing to android-navigation.
Migrate an Android XML View to Jetpack Compose following a structured 10-step workflow. Use when converting XML layouts to Compose, setting up Compose in an existing View-based project, or incrementally adopting Compose.
Write correct coroutine scopes, lifecycle collection, and dispatcher injection in Android production code. Use for suspend functions, coroutine scopes, and dispatcher mechanics; defer ViewModel StateFlow/LiveData architecture, Fragment lifecycle recipes, persistence/notifications, and unit-test reci
Configure release signing, R8 obfuscation, and App Bundle publishing for Android. Use when setting up signing configs, enabling minification, adding ProGuard keep rules, or preparing for Play Store submission.
Enforce Material Design 3 theming and design token usage in Jetpack Compose. Use when implementing M3 components, color schemes, typography, or design tokens.
Related devops skillsscan passed
Build monitoring dashboards that answer real operator questions for Grafana, SigNoz, and similar platforms. Use when turning metrics into a working dashboard instead of a vanity board.
Configure deployment settings for /land-and-deploy.
Build, migrate, and deploy Next.js apps on Cloudflare Workers with vinext. Use when starting a Next.js project on Cloudflare, moving an existing app to Workers, choosing between vinext and OpenNext, or setting up vinext for Workers. For setup, migration, or deployment, install vinext's upstream skil
Deploy tRPC on AWS Lambda with awsLambdaRequestHandler() from @trpc/server/adapters/aws-lambda for API Gateway v1 (REST, APIGatewayProxyEvent) and v2 (HTTP, APIGatewayProxyEventV2), and Lambda Function URLs. Enable response streaming with awsLambdaStreamingRequestHandler() wrapped in awslambda.strea
Instruments code so production behavior is visible and diagnosable. Use when adding logging, metrics, tracing, or alerting. Use when shipping any feature that runs in production and you need evidence it works. Use when production issues are reported but you can't tell what happened from the availabl
Deploys and manages full-stack web applications (Next.js, Angular) with Server-Side Rendering (SSR) using Firebase App Hosting. Use when deploying Next.js/Angular apps, configuring apphosting.yaml or firebase.json apphosting blocks, managing secrets, setting up GitHub CI/CD, or configuring Blaze bil