Sha256: b541b9e1a3a48213f135a032db5920bdfdca8f4aa8476dcf71f64a3332e718fa

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

require 'logsformyfamily/logger'
require 'logsformyfamily/rack'
require 'logsformyfamily/sidekiq'
require 'logsformyfamily/version'

module LogsForMyFamily
  class Error < StandardError; end

  class << self
    attr_accessor :configuration
  end

  def self.logger
    Thread.current.thread_variable_get(:'logsformyfamily.logger')
  end

  def self.logger=(val)
    Thread.current.thread_variable_set(:'logsformyfamily.logger', val)
  end

  module LocalLogger
    def logger
      @logger ||= LogsForMyFamily.logger || LogsForMyFamily::Logger.new
    end
  end

  def self.configure
    yield(configuration)
  end

  class Configuration
    attr_accessor :version, :hostname, :app_name, :backends, :request_id

    def initialize
      @version = `git rev-parse --short HEAD`.chomp
      @hostname = `hostname`.strip
      @app_name = ENV['NEWRELIC_APP']
      @backends = []
      @request_id = proc { |env| env['core_app.request_id'] }
    end

    def to_h
      {
        version: @version,
        hostname: @hostname,
        app_name: @app_name
      }
    end
  end

  self.configuration ||= Configuration.new
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logsformyfamily-0.2.1 lib/logsformyfamily.rb