Sha256: 9432ddc36d1a3d28e797edc9f4ea7ef31f3ba59ad845ac054856ae4f16df04c8

Contents?: true

Size: 1015 Bytes

Versions: 20

Compression:

Stored size: 1015 Bytes

Contents

# Require the logging gem.
require 'logging'

# The populate logger class.
class PopulateLogger

  # Configures the logger.
  #
  # @return [Logger] The logger instance after configuration.
  def self.setup
    configure
    logger
  end

  private

  # Configures the level.
  #
  # @param [Symbol] The log level. (defaults to :info)
  def self.level=(level)
    @level = level
  end

  # Returns the level.
  #
  # @param [String] The configured level. (defaults to :info)
  def self.level
    @level or :info
  end

  # Returns the configured logger.
  #
  # @return [Logger, #info, #debug, #warn] The logger instance.
  def self.logger
    logger = Logging.logger['example_logger']
    logger.add_appenders Logging.appenders.stdout, Logging.appenders.file(@path)
    logger.level = level
    logger
  end

  # Configures the path of the log file.
  #
  # @return [String] The path of the log file.
  def self.configure
    @path = defined?(Rails) ? "#{Rails.root}/log/populator.log" : 'populator.log'
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
smilodon-0.3.0 lib/smilodon/logger.rb
smilodon-0.2.8 lib/smilodon/logger.rb
smilodon-0.2.7 lib/smilodon/logger.rb
smilodon-0.2.6 lib/smilodon/logger.rb
smilodon-0.2.5 lib/smilodon/logger.rb
smilodon-0.2.4 lib/smilodon/logger.rb
smilodon-0.2.3 lib/smilodon/logger.rb
smilodon-0.2.2 lib/smilodon/logger.rb
db-populator-0.1.13 lib/populator/logger.rb
db-populator-0.1.12 lib/populator/logger.rb
db-populator-0.1.11 lib/populator/logger.rb
db-populator-0.1.10 lib/populator/logger.rb
db-populator-0.1.9 lib/populator/logger.rb
db-populator-0.1.8 lib/populator/logger.rb
db-populator-0.1.6 lib/populator/logger.rb
db-populator-0.1.5 lib/populator/logger.rb
db-populator-0.1.4 lib/populator/logger.rb
db-populator-0.1.3 lib/populator/logger.rb
db-populator-0.1.2 lib/populator/logger.rb
db-populator-0.1.1 lib/populator/logger.rb