Skip to content

Conversation

@cuonglm
Copy link
Collaborator

@cuonglm cuonglm commented Aug 28, 2025

Implements custom log level functionality allowing users to define custom levels between existing built-in levels (e.g., NOTICE between INFO and WARN) without breaking existing APIs.

Key Features:

  • Custom level registry system with thread-safe global registry
  • Semantic ordering support via IsBetween() method
  • Custom levels can be positioned between existing levels using specific int8 values
  • Stack trace and caller information properly handled for custom levels
  • Backward compatible - Level remains int8, no breaking changes

Implementation Details:

  • New zapcore/customlevels package for level metadata management
  • CustomLevelMetadata struct with name, value, color, and metadata
  • RegisterCustomLevelBetween() for semantic positioning
  • Enhanced Level type with IsCustom(), Custom(), and IsBetween() methods
  • Fixed addStack logic in logger.check() to support custom levels
  • Updated encoder configurations for proper custom level handling

Implements custom log level functionality allowing users to define custom
levels between existing built-in levels (e.g., NOTICE between INFO and WARN)
without breaking existing APIs.

Key Features:
- Custom level registry system with thread-safe global registry
- Semantic ordering support via IsBetween() method
- Custom levels can be positioned between existing levels using specific int8 values
- Stack trace and caller information properly handled for custom levels
- Backward compatible - Level remains int8, no breaking changes

Implementation Details:
- New zapcore/customlevels package for level metadata management
- CustomLevelMetadata struct with name, value, color, and metadata
- RegisterCustomLevelBetween() for semantic positioning
- Enhanced Level type with IsCustom(), Custom(), and IsBetween() methods
- Fixed addStack logic in logger.check() to support custom levels
- Updated encoder configurations for proper custom level handling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants