GoKit’sDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/AndresGT/GoKit/llms.txt
Use this file to discover all available pages before exploring further.
logger package is a structured, production-ready logging solution designed for Go APIs built on top of Gin. Every log entry carries a unique ID, a severity level, a message, a timestamp, and an optional bag of typed fields — giving you rich, queryable logs without any boilerplate. A zero-configuration global instance is ready from the moment you import the package, so you can start logging immediately and layer in customisation later.
Import
Core types
The following types form the foundation of the logger package:Log levels
GoKit defines seven severity levels as ordered integer constants. The logger silently drops any entry whose level is below the configuredMinLevel.
| Constant | Icon | When to use |
|---|---|---|
DebugLevel | 🔍 | Detailed technical information useful during development |
InfoLevel | ℹ | General operational messages — server started, request completed |
WarnLevel | ⚠ | Something unexpected happened but the application can continue |
ErrorLevel | ✖ | A recoverable error occurred; investigate but no restart needed |
FatalLevel | 💀 | An unrecoverable error; logs the message then calls os.Exit(1) |
SecurityLevel | 🔒 | Audit-grade events: login attempts, authorization failures, rate limits |
OffLevel | — | Disables all output entirely |
The global logger
The package keeps a thread-safe global*Logger instance that is lazily initialised with InfoLevel and colored console output the first time it is accessed. You never need to create a logger to get started.
logger.Fatal logs the message and immediately calls os.Exit(1). Reserve it for truly unrecoverable startup failures.Context helpers
All four helper functions return a new*Logger that inherits the global logger’s writers and minimum level, with the supplied fields merged in. The global logger is never modified.
Enabling and disabling logs
Two convenience functions control the global logger’s minimum level at runtime — useful for integration tests or feature-flagged verbose modes.SetMinLevel on any *Logger instance directly. See the Configuration page for details.
What’s next
Configuration
Customise log levels, colors, service names, and initialise the global logger at startup with
InitGlobal.Writers
Route log entries to the console, a JSON file, a PostgreSQL database, or your own custom destination.
Gin Integration
Add per-request logging middleware, panic recovery, and route-registration helpers to your Gin router.