Sha256: 8236497cbc4d747a00e4eb728c8bd45deaf6ebe7907fcc2756b8397154a2bb5e

Contents?: true

Size: 733 Bytes

Versions: 1

Compression:

Stored size: 733 Bytes

Contents

require 'logger'

module Lux
  LOGGER_CACHE ||= {}

  # Lux.logger(:foo).warn 'bar'
  def logger name = nil
    raise "Logger name is required" unless name

    LOGGER_CACHE[name] ||= begin
      output_location = Lux.config.logger_path_mask % name
      LOGGER_CACHE[name] = Logger.new output_location,  Lux.config.logger_files_to_keep, Lux.config.logger_file_max_size

      if Lux.config.logger_formatter
        LOGGER_CACHE[name].formatter = Lux.config.logger_formatter
      end
      LOGGER_CACHE[name]
    end
  end

  def log what = nil, &block
    return unless Lux.env.screen_log?
    # return if Lux.current.nav.format && !Lux.current.no_cache?
    what = block.call if block
    print what.to_s + "\n" if what
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lux-fw-0.6.2 ./lib/lux/logger/lux_adapter.rb