Skip to content

Releases: rendis/abslog

v3.1.1 - Enhanced Type Safety for Context Keys

Choose a tag to compare

@rendis rendis released this 29 Sep 10:05

πŸ”§ 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 returns ContextKeyType instead of string
  • Automatic type conversion in SetCtxKey(): String parameters are automatically converted to ContextKeyType

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

⚠️ Minor breaking change: 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

Choose a tag to compare

@rendis rendis released this 28 Sep 17:51

✨ 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.

v3.0.1

Choose a tag to compare

@rendis rendis released this 28 Jul 16:52
add filename to log