lib/lucid.rb in lucid-0.3.3 vs lib/lucid.rb in lucid-0.4.0
- old
+ new
@@ -1,20 +1,34 @@
$:.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/runtime'
+require 'lucid/context_loader'
require 'lucid/cli/app'
require 'lucid/step_definitions'
-require 'lucid/term/ansicolor'
+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
@@ -25,10 +39,15 @@
end
end
class LogFormatter < ::Logger::Formatter
def call(severity, time, progname, msg)
- "\n[ LUCID (#{severity}) ] #{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