Module: LogStruct::SemanticLogger
- Defined in:
- lib/log_struct/semantic_logger/setup.rb,
lib/log_struct/semantic_logger/logger.rb,
lib/log_struct/semantic_logger/formatter.rb,
lib/log_struct/semantic_logger/color_formatter.rb
Overview
SemanticLogger Integration
LogStruct uses SemanticLogger as its core logging engine, providing significant performance and functionality benefits over Rails' default logger:
Performance Benefits
- Asynchronous logging: Logs are written in a background thread, eliminating I/O blocking in your main application threads
- High throughput: Can handle 100,000+ log entries per second
- Memory efficient: Structured data processing with minimal allocations
- Zero-copy serialization: Direct JSON generation without intermediate objects
Reliability Benefits
- Thread-safe: All operations are thread-safe by design
- Graceful degradation: Continues logging even if appenders fail
- Error isolation: Logging errors don't crash your application
- Buffered writes: Reduces disk I/O with intelligent batching
Feature Benefits
- Multiple appenders: Log to files, STDOUT, databases, cloud services simultaneously
- Structured metadata: Rich context including process ID, thread ID, tags, and more
- Log filtering: Runtime filtering by logger name, level, or custom rules
- Formatters: Pluggable output formatting (JSON, colorized, custom)
- Metrics integration: Built-in performance metrics and timing data
Development Experience
- Colorized output: Beautiful, readable logs in development with ANSI colors
- Tagged logging: Hierarchical context tracking (requests, jobs, etc.)
- Debugging tools: Detailed timing and memory usage information
- Hot reloading: Configuration changes without application restart
Production Benefits
- Log rotation: Automatic file rotation with size/time-based policies
- Compression: Automatic log compression to save disk space
- Cloud integration: Direct integration with CloudWatch, Splunk, etc.
- Alerting: Built-in support for error alerting and monitoring
LogStruct Specific Enhancements
- Type safety: Full Sorbet type annotations for compile-time error detection
- Structured data: Native support for LogStruct's typed log structures
- Filtering integration: Seamless integration with LogStruct's data filters
- Error handling: Enhanced error reporting with full stack traces and context
SemanticLogger is a production-grade logging framework used by companies processing millions of requests per day. It provides the performance and reliability needed for high-traffic Rails applications while maintaining an elegant developer experience.
Defined Under Namespace
Modules: Setup Classes: ColorFormatter, Formatter, Logger