struct
Logit::NamespaceBinding
- Logit::NamespaceBinding
- Struct
- Value
- Object
Overview
Binds a namespace pattern to a log level for filtering.
Namespace bindings allow different log levels for different parts of your
codebase. They are created via Backend#bind or Config#bind.
Pattern Syntax
Patterns use Crystal's :: namespace separator with wildcards:
MyApp::*- Matches classes directly inMyApp(e.g.,MyApp::User)MyApp::**- Matches classes inMyAppand all nested namespacesMyApp::Database::Query- Matches exactly this class
Examples
Logit.configure do |config|
console = config.console(level: Logit::LogLevel::Info)
# Reduce noise from database classes
config.bind("MyApp::Database::*", Logit::LogLevel::Warn, console)
# But keep verbose logging for query builder
config.bind("MyApp::Database::QueryBuilder", Logit::LogLevel::Debug, console)
end
Defined in:
logit/namespace_binding.crConstructors
-
.new(pattern : String, level : LogLevel)
Creates a new binding.
Instance Method Summary
-
#level : LogLevel
The log level for namespaces matching this pattern.
-
#level=(level : LogLevel)
The log level for namespaces matching this pattern.
-
#matches?(namespace : String) : Bool
Checks if a namespace matches this pattern.
-
#pattern : String
The namespace pattern (e.g., "MyApp::Database::*").
-
#pattern=(pattern : String)
The namespace pattern (e.g., "MyApp::Database::*").
Constructor Detail
Creates a new binding. Raises if the pattern is invalid.