lib/ntail/log_line.rb in ntail-0.1.0 vs lib/ntail/log_line.rb in ntail-0.2.0

- old
+ new

@@ -121,20 +121,31 @@ # for now, until we make it fancier... def method_missing(method, *params) raw_line.send method, *params end + @@output_format = :ansi + + def self.set_output(output) + @@output_format = output + end + @@parser = FormattingParser.new @@result = @@format = nil def self.format= format unless @@result = @@parser.parse(@@format = format) raise @@parser.terminal_failures.join("\n") else def @@result.value(log_line, color) - elements.map { |element| element.value(log_line, color) }.join + if @@output_format == :ansi + elements.map { |element| element.value(log_line, color) }.join + elsif @@output_format == :html + line = elements.map { |element| element.value(log_line, nil) }.join + "<span style=\"font-family: monospace; color: #{color}\">%s</span></br>" % line + end end end end self.format = "%t - %a - %s - %r - %U - %R" @@ -144,10 +155,10 @@ # simple but boring: # raw_line.to_s # a bit less boring: color = options[:color] && if redirect_status? - :yellow + @@output_format == :ansi ? :yellow : :orange elsif !success_status? :red else :default end