Module: LambdaLoadout::Global
- Defined in:
- lib/lambda_loadout/global.rb
Overview
Module-level convenience methods for quick access
Provides a simple API similar to common logging modules:
LambdaLoadout.logger.info("message")
LambdaLoadout.metrics.add_metric(...)
Class Attribute Summary collapse
-
.log_level ⇒ Object
Configuration.
-
.logger ⇒ LambdaLoadout::Logger
Get or create the global logger instance.
-
.metrics ⇒ LambdaLoadout::Metrics
Get or create the global metrics instance.
-
.namespace ⇒ Object
Configuration.
-
.service ⇒ Object
Configuration.
Class Method Summary collapse
-
.reset! ⇒ void
Reset global instances (useful for testing).
Class Attribute Details
.log_level ⇒ Object
Configuration
23 24 25 |
# File 'lib/lambda_loadout/global.rb', line 23 def log_level @log_level end |
.logger ⇒ LambdaLoadout::Logger
Get or create the global logger instance
28 29 30 31 32 33 |
# File 'lib/lambda_loadout/global.rb', line 28 def logger @logger ||= LambdaLoadout::Logger.new( service: service || ENV.fetch('POWERTOOLS_SERVICE_NAME', nil), level: log_level || :info ) end |
.metrics ⇒ LambdaLoadout::Metrics
Get or create the global metrics instance
38 39 40 41 42 43 |
# File 'lib/lambda_loadout/global.rb', line 38 def metrics @metrics ||= LambdaLoadout::Metrics.new( namespace: namespace || ENV['POWERTOOLS_METRICS_NAMESPACE'] || 'LambdaLoadout', service: service || ENV.fetch('POWERTOOLS_SERVICE_NAME', nil) ) end |
.namespace ⇒ Object
Configuration
23 24 25 |
# File 'lib/lambda_loadout/global.rb', line 23 def namespace @namespace end |
.service ⇒ Object
Configuration
23 24 25 |
# File 'lib/lambda_loadout/global.rb', line 23 def service @service end |
Class Method Details
.reset! ⇒ void
This method returns an undefined value.
Reset global instances (useful for testing)
48 49 50 51 |
# File 'lib/lambda_loadout/global.rb', line 48 def reset! @logger = nil @metrics = nil end |