Sha256: e618bd2aa6a90145657002ebddfa23f81fbf19415634ca0e288118ce123f543a

Contents?: true

Size: 1.52 KB

Versions: 119

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

class ReeLogger::Logger
  include Ree::BeanDSL

  bean :logger do
    singleton
    factory :build

    link :build_logger
    link :config
    link :not_blank, from: :ree_object
    link :is_blank, from: :ree_object
    link 'ree_logger/rate_limiter', -> { RateLimiter }
    link 'ree_logger/appenders/file_appender', -> { FileAppender }
    link 'ree_logger/appenders/stdout_appender', -> { StdoutAppender }
    link 'ree_logger/appenders/rollbar_appender', -> { RollbarAppender }
  end

  def build
    appenders = []

    if config.levels.file
      if is_blank(config.file_path)
        raise ArgumentError, "use ENV['LOG_FILE_PATH'] to specify path to log file"
      end

      appenders << FileAppender.new(
        config.levels.file, nil, config.file_path, auto_flush: config.file_auto_flush
      )
    end

    if config.levels.stdout
      appenders << StdoutAppender.new(
        config.levels.stdout, nil
      )
    end

    if config.rollbar.enabled
      opts = {}
      opts[:branch] = config.rollbar.branch if config.rollbar.branch
      opts[:host] = config.rollbar.host if config.rollbar.host

      appenders << RollbarAppender.new(
        config.levels.rollbar,
        access_token: config.rollbar.access_token,
        environment: config.rollbar.environment,
        **opts
      )
    end

    build_logger(
      appenders,
      ENV['APP_NAME'],
      RateLimiter.new(
        config.rate_limit.interval,
        config.rate_limit.max_count
      ),
      config.default_filter_words
    )
  end
end

Version data entries

119 entries across 119 versions & 1 rubygems

Version Path
ree_lib-1.0.124 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.123 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.122 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.121 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.120 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.119 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.118 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.117 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.116 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.115 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.114 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.113 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.112 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.111 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.110 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.109 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.108 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.107 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.106 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.105 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb