# charmbracelet/log

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/charmbracelet-log).**

3,121 stars · 87 forks · Go · mit

## Links

- GitHub: https://github.com/charmbracelet/log
- awesome-repositories: https://awesome-repositories.com/repository/charmbracelet-log.md

## Topics

`golang` `logging`

## Description

This is a structured logging library designed to produce logs using key-value pairs, severity levels, and machine-readable formats. It provides a toolkit for creating logs that are consistent for both human review and machine parsing.

The project is distinguished by its focus on terminal visualization, using a styling system to apply colors and prefixes to log entries for improved readability in consoles. It also includes a specialized adapter to convert standard library log calls into structured events by inferring severity levels from message prefixes.

The library manages metadata through contextual sub-loggers that attach persistent attributes and automatic source location information to entries. It supports multiple serialization formats, including JSON and logfmt, and provides source attribution by analyzing the call stack to identify the origin of log events.

The system integrates with the standard slog package via a custom handler to route structured logs through its formatting engine.

## Tags

### System Administration & Monitoring

- [Structured Logging](https://awesome-repositories.com/f/system-administration-monitoring/structured-logging.md) — Implements structured logging by recording operational data as machine-readable key-value pairs.
- [Severity Level Filtering](https://awesome-repositories.com/f/system-administration-monitoring/audit-log-filters/severity-level-filtering.md) — Filters log messages based on a minimum severity threshold such as Info or Error. ([source](https://github.com/charmbracelet/log#readme))
- [Contextual Logging](https://awesome-repositories.com/f/system-administration-monitoring/contextual-logging.md) — Injects persistent metadata and source location information into log entries to enable system-wide tracing.
- [Log Configuration](https://awesome-repositories.com/f/system-administration-monitoring/log-configuration.md) — Provides global settings for controlling log severity levels, time formats, and output prefixes. ([source](https://github.com/charmbracelet/log/blob/main/options.go))
- [Logger Hierarchies](https://awesome-repositories.com/f/system-administration-monitoring/log-management/logger-hierarchies.md) — Implements hierarchical logger structures where child loggers inherit metadata and attributes from their parents.
- [Contextual Logger Instances](https://awesome-repositories.com/f/system-administration-monitoring/log-management/logger-hierarchies/independent-logger-instances/contextual-logger-instances.md) — Provides a logging system capable of creating child loggers that carry persistent, scoped metadata.
- [Structured Log Field Attachments](https://awesome-repositories.com/f/system-administration-monitoring/structured-logging/structured-log-field-attachments.md) — Allows adding structured key-value pairs to log entries to provide consistent context throughout an execution. ([source](https://github.com/charmbracelet/log/blob/main/options.go))
- [Severity Inference Engines](https://awesome-repositories.com/f/system-administration-monitoring/audit-log-filters/severity-level-filtering/severity-inference-engines.md) — Infers log severity levels from unstructured strings by matching message prefixes against defined patterns.
- [Component Identifiers](https://awesome-repositories.com/f/system-administration-monitoring/logging-and-telemetry/log-analysis/log-entry-annotations/component-identifiers.md) — Allows prepending specific strings to log entries to identify which component emitted the message. ([source](https://github.com/charmbracelet/log/blob/main/logger_test.go))
- [Logging Integrations](https://awesome-repositories.com/f/system-administration-monitoring/system-logging/logging-frameworks/logging-integrations.md) — Implements a custom handler for the standard slog package to route structured logs through its formatting engine. ([source](https://github.com/charmbracelet/log#readme))

### Data & Databases

- [Log Formatters](https://awesome-repositories.com/f/data-databases/data-serialization-formats/data-formats/json/log-formatters.md) — Provides pluggable formatters to serialize structured logs into multiple formats including JSON and logfmt.
- [Logfmt Serializers](https://awesome-repositories.com/f/data-databases/data-serialization-formats/json-serialization/json-message-serializers/structured-log-serializers/logfmt-serializers.md) — Serializes log entries into key-value pairs following the logfmt standard to handle complex data types. ([source](https://github.com/charmbracelet/log/blob/main/logfmt_test.go))
- [Logfmt Serializers](https://awesome-repositories.com/f/data-databases/data-serialization-formats/data-formats/json/log-formatters/logfmt-serializers.md) — Includes a dedicated serializer for converting structured log data into the logfmt standard.

### Development Tools & Productivity

- [Terminal Output Stylers](https://awesome-repositories.com/f/development-tools-productivity/terminal-output-stylers.md) — Applies visual styles and color-coded escape sequences to log output for improved console readability.
- [Runtime Call-Stack Capturers](https://awesome-repositories.com/f/development-tools-productivity/call-stack-navigators/runtime-call-stack-capturers.md) — Analyzes the runtime call stack to bypass wrapper functions and identify the original source of a log event. ([source](https://github.com/charmbracelet/log#readme))
- [Standard Library Adapters](https://awesome-repositories.com/f/development-tools-productivity/logging-libraries/standard-library-adapters.md) — Wraps standard library logging interfaces to integrate them into a structured logging pipeline.

### Programming Languages & Runtimes

- [Structured Logging Libraries](https://awesome-repositories.com/f/programming-languages-runtimes/structured-logging-libraries.md) — Provides a comprehensive toolkit for producing structured logs with key-value pairs and severity levels.
- [Logging Libraries](https://awesome-repositories.com/f/programming-languages-runtimes/logging-libraries.md) — Provides adapters that convert standard library log calls into structured events to modernize legacy logging.

### Software Engineering & Architecture

- [Persistent Log Context](https://awesome-repositories.com/f/software-engineering-architecture/contextual-data-injection/contextual-metadata-injection/persistent-context-managers/persistent-log-context.md) — Attaches persistent metadata fields to logger instances to ensure consistent context across all subsequent logs. ([source](https://github.com/charmbracelet/log/blob/main/logger_test.go))
- [JSON Formats](https://awesome-repositories.com/f/software-engineering-architecture/custom-log-formatting/json-formats.md) — Serializes log entries into machine-readable JSON and logfmt formats for observability tool compatibility.
- [Adapter Patterns](https://awesome-repositories.com/f/software-engineering-architecture/adapter-patterns.md) — Uses adapter patterns to bridge the gap between standard library logging and structured logging interfaces.
- [Custom Log Formatting](https://awesome-repositories.com/f/software-engineering-architecture/custom-log-formatting.md) — Supports converting structured log data into multiple interchangeable formats including text, JSON, and logfmt. ([source](https://github.com/charmbracelet/log/blob/main/formatter.go))
- [Source Location Capture](https://awesome-repositories.com/f/software-engineering-architecture/source-location-capture.md) — Automatically records the source file, line number, and function name for every emitted log entry. ([source](https://github.com/charmbracelet/log/blob/main/options_test.go))

### User Interface & Experience

- [Log Level Visual Styling](https://awesome-repositories.com/f/user-interface-experience/label-formatting/log-level-visual-styling.md) — Maps specific log levels to visual color profiles and formatting rules for improved terminal readability.

### Artificial Intelligence & ML

- [Log Metadata Injectors](https://awesome-repositories.com/f/artificial-intelligence-ml/automatic-logging/automatic-field-injectors/log-metadata-injectors.md) — Automatically injects constant fields, timestamps, and source location information into every emitted log entry. ([source](https://github.com/charmbracelet/log/blob/main/logger.go))
