Sha256: 149c08a0c5f2ac90fbccb3925ec76130253762d84373f833537c039902e095db

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

$:.unshift(File.dirname(__FILE__)) unless
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))

require 'pp'
require 'yaml'
require 'logger'
require 'stringio'
require 'lucid/platform'
require 'lucid/context_loader'
require 'lucid/cli/app'
require 'lucid/step_definitions'
require 'lucid/ansicolor'

module Lucid
  class << self
    attr_accessor :wants_to_quit

    def breakdown(*args)
      current_output = $stdout
      begin
        msg_string = StringIO.new
        $stdout = msg_string
        pp(*args)
      ensure
        $stdout = current_output
      end
      msg_string.string
    end

    def logger
      return @log if @log
      @log = Logger.new(STDOUT)
      @log.level = Logger::INFO
      @log
    end

    def logger=(logger)
      @log = logger
    end
  end

  class LogFormatter < ::Logger::Formatter
    def call(severity, time, progname, msg)
      if msg.is_a?(String)
        "\n[ LUCID (#{severity}) ] #{msg}\n"
      else
        msg = Lucid.breakdown(msg)
        "\n[ LUCID (#{severity}) ] \n#{msg}\n"
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lucid-0.4.1 lib/lucid.rb
lucid-0.4.0 lib/lucid.rb