Class: Makit::Logging::Sinks::Base
- Inherits:
-
Object
- Object
- Makit::Logging::Sinks::Base
- Defined in:
- lib/makit/logging/sinks/base.rb
Overview
Base class for all logging sinks
Sinks provide a way to output log requests to various destinations like console, files, or external services. This follows the same pattern as the commands middleware but focuses on output rather than transformation.
Direct Known Subclasses
Instance Method Summary collapse
-
#applicable?(_log_request) ⇒ Boolean
Check if this sink should be applied to the given log request.
-
#call(log_request) {|LogRequest| ... } ⇒ LogRequest
Execute sink logic.
-
#config ⇒ Hash
Get sink configuration.
-
#name ⇒ String
Get sink name for logging and debugging.
Instance Method Details
#applicable?(_log_request) ⇒ Boolean
Check if this sink should be applied to the given log request
Override this method to provide conditional sink application based on log request properties like level, message, or context.
45 46 47 |
# File 'lib/makit/logging/sinks/base.rb', line 45 def applicable?(_log_request) true end |
#call(log_request) {|LogRequest| ... } ⇒ LogRequest
Execute sink logic
This method must be implemented by subclasses to provide the actual sink functionality. The pattern is to output the log request to the destination, then call the block to continue the sink chain.
34 35 36 |
# File 'lib/makit/logging/sinks/base.rb', line 34 def call(log_request, &block) raise NotImplementedError, "#{self.class.name} must implement #call" end |
#config ⇒ Hash
Get sink configuration
Override this method to provide sink-specific configuration.
61 62 63 |
# File 'lib/makit/logging/sinks/base.rb', line 61 def config {} end |
#name ⇒ String
Get sink name for logging and debugging
52 53 54 |
# File 'lib/makit/logging/sinks/base.rb', line 52 def name self.class.name.split("::").last end |