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.23 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.22 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.21 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.20 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.19 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.18 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.17 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.16 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.15 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.14 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.13 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.12 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.11 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.10 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.9 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.8 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.7 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.6 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.5 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb