Module: Mozart::Logger
- Defined in:
- lib/mozart/logger.rb,
lib/mozart/logger/version.rb
Constant Summary collapse
- VERSION =
"1.2.0"
Class Method Summary collapse
- .cloudwatch_driver(opts) ⇒ Object
- .cloudwatch_namespace(opts) ⇒ Object
- .drivers(opts, log_path) ⇒ Object
- .json_driver(log_path) ⇒ Object
- .metric_driver(opts) ⇒ Object
- .production? ⇒ Boolean
- .setup(opts, log_path) ⇒ Object
- .statsd_driver(opts) ⇒ Object
Class Method Details
.cloudwatch_driver(opts) ⇒ Object
34 35 36 |
# File 'lib/mozart/logger.rb', line 34 def self.cloudwatch_driver(opts) Alephant::Logger::CloudWatch.new cloudwatch_namespace(opts) end |
.cloudwatch_namespace(opts) ⇒ Object
38 39 40 41 42 |
# File 'lib/mozart/logger.rb', line 38 def self.cloudwatch_namespace(opts) opts.tap do |h| h[:namespace] = h[:namespace] % BBC::Cosmos::Config.cosmos.environment end end |
.drivers(opts, log_path) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/mozart/logger.rb', line 14 def self.drivers(opts, log_path) [].tap do |drivers| drivers << json_driver(log_path) drivers << metric_driver(opts) end end |
.json_driver(log_path) ⇒ Object
26 27 28 |
# File 'lib/mozart/logger.rb', line 26 def self.json_driver(log_path) Alephant::Logger::JSON.new log_path end |
.metric_driver(opts) ⇒ Object
21 22 23 24 |
# File 'lib/mozart/logger.rb', line 21 def self.metric_driver(opts) return statsd_driver(opts[:statsd]) if opts[:statsd] cloudwatch_driver(opts[:cloudwatch]) if opts[:cloudwatch] && production? end |
.production? ⇒ Boolean
44 45 46 |
# File 'lib/mozart/logger.rb', line 44 def self.production? BBC::Cosmos::Config.cosmos.environment == "live" end |
.setup(opts, log_path) ⇒ Object
10 11 12 |
# File 'lib/mozart/logger.rb', line 10 def self.setup(opts, log_path) Alephant::Logger.setup drivers(opts, log_path) end |
.statsd_driver(opts) ⇒ Object
30 31 32 |
# File 'lib/mozart/logger.rb', line 30 def self.statsd_driver(opts) Alephant::Logger::Statsd.new opts end |