Sha256: 753f9d92241a3b679bced73d7e6defd7da3a874f76aae946abe80d665bb7b0ab

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

module Timber
  # Intermediary class between frameworks and Timber. Defines
  # requirements and normalized the setup process.
  class Bootstrap
    def self.bootstrap!(*args)
      new(*args).bootstrap!
    rescue Exception => e
      # Failsafe to ensure Timber never takes down the app
      Config.logger.exception(e)
    end

    attr_reader :middleware, :insert_before

    def initialize(middleware, insert_before)
      @middleware = middleware
      @insert_before = insert_before
    end

    def bootstrap!
      return false unless enabled?
      Probes.insert!(middleware, insert_before)
      log_started
      true
    end

    private
      def enabled?
        if !Config.enabled?
          Config.logger.warn("Skipping bootstrap, Timber::Config.enabled is not true")
          false
        else
          true
        end
      end

      def log_started
        Config.logger.info(" _,-,")
        Config.logger.info("T_  | Timber enabled")
        Config.logger.info("||`-'")
        Config.logger.info("||")
        Config.logger.info("||")
        Config.logger.info("~~")
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
timberio-1.0.0.beta1 lib/timber/bootstrap.rb