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.84 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.83 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.82 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.81 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.80 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.79 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.78 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.77 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.76 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.75 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.74 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.73 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.72 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.71 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.70 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.69 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.68 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.67 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.66 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb
ree_lib-1.0.65 lib/ree_lib/packages/ree_logger/package/ree_logger/beans/logger.rb