0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Private gem setting up logging/metrics for Mozart
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Project Readme

Mozart::Logger

Internal gem for setting up structured logging and metrics for use within our Mozart service applications.

It is an abstraction wrapping around our open-source software Alephant Logger.

Installation

Add this line to your application's Gemfile:

group :production do
  gem "mozart-logger", "1.0.0", :git => "git@github.com:bbc/mozart-logger.git"
end

And then execute:

$ bundle install

Setup

require "mozart/logger"

opts = {
  :statsd => {
    :host      => ENV["STATSD_HOST"],
    :port      => 8125,
    :namespace => "mozart-routing"
  },
  :cloudwatch => {
    :namespace => ENV["CLOUDWATCH_NAMESPACE"]
  }
}

Mozart::Logger.setup opts, ENV["APP_LOG_LOCATION"] # configures Alephant Logger

use Rack::CommonLogger, Alephant::Logger.get_logger # optional

Note: you should only provide one key
either :statsd or :cloudwatch
the latter will be ignored if both provided

Usage

require "alephant/logger"

class Foo
  include include Alephant::Logger

  def initialize
    logger.info(
      "event"   => "ClassInitialized",
      "method"  => "#{self.class.name}##{__method__}",
      "someKey" => 123
    )
  end
end

Note: for more details, refer to the following gems
Alephant-Logger-CloudWatch, Alephant-Logger-Statsd and Alephant-Logger-JSON