Repository navigation
Releases: rendis/abslog
Release list
v3.1.1 - Enhanced Type Safety for Context Keys
π§ Improvements
Enhanced Type Safety for Context Keys
- Introduced
ContextKeyType: Added a custom type for context keys to improve type safety - Updated
GetCtxKey()return type: Now returnsContextKeyTypeinstead ofstring - Automatic type conversion in
SetCtxKey(): String parameters are automatically converted toContextKeyType
Why This Matters
This change addresses Go's static analysis warning SA1029: "should not use built-in type string as key for value; define your own type to avoid collisions". By using a custom type for context keys, we ensure:
- β Compliance with Go's context package best practices
- β Prevention of key collisions between packages
- β Better static analysis and code quality
- β
Seamless usage with
context.WithValue()without warnings
Breaking Changes
GetCtxKey() now returns ContextKeyType instead of string. If you were directly using the return value as a string, you may need to cast it or adjust your code.
Migration
Most users won't need to change anything. If you encounter type issues:
// Before (if you were doing direct string comparison)
if someKey == abslog.GetCtxKey() { ... }
// After
if someKey == string(abslog.GetCtxKey()) { ... }Full Changelog: v3.1.0...v3.1.1
v3.1.0 - Enhanced Context Support and Performance Improvements
β¨ New Features
- π§ Flexible Context Configuration: Added ContextKey method to AbsLogBuilder for configurable context key management
- π― Enhanced Logging Interface: Introduced LoggerAdapter for consistent logging across different implementations
β‘ Performance Improvements
- π Optimized Context Formatting: Implemented strings.Builder for more efficient context value formatting
- π Streamlined Operations: Combined context values with log messages in single operations for better performance
π οΈ Refactoring & Code Quality
- π Modern Go Syntax: Replaced interface{} with any for better consistency
- ποΈ Default Configuration: Added default values for context configuration with enhanced setter functions
- π§Ή Simplified API: Removed caller info and improved context value handling
π Documentation & Community
- π Enhanced README: Added output examples and clarified logger configuration methods
- π€ Contributing Guide: Added comprehensive guide to enhance community collaboration
- π Improved Documentation: Better package documentation with context support examples
π§ Dependencies & Maintenance
- β¬οΈ Updated Dependencies: Bumped go.uber.org/zap to v1.27.0
- ποΈ Cleanup: Removed unused dependencies
- π Go Version: Updated to Go 1.25.1
This release focuses on enhancing the logging experience with better context support, improved performance, and
comprehensive documentation updates.