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.104 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.103 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.102 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.101 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.100 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.99 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.98 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.97 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.96 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.95 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.94 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.93 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.92 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.91 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.90 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.89 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.88 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.87 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.86 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.85 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb