Class: Build::CompactFormatter
- Inherits:
-
Object
- Object
- Build::CompactFormatter
- Defined in:
- lib/build/logger.rb
Instance Method Summary collapse
- #call(severity, datetime, progname, message) ⇒ Object
- #chdir_string(options) ⇒ Object
- #format_command(arguments) ⇒ Object
-
#initialize(verbose: true) ⇒ CompactFormatter
constructor
A new instance of CompactFormatter.
- #time_offset_string ⇒ Object
Constructor Details
#initialize(verbose: true) ⇒ CompactFormatter
Returns a new instance of CompactFormatter.
26 27 28 29 |
# File 'lib/build/logger.rb', line 26 def initialize(verbose: true) @start = Time.now @verbose = verbose end |
Instance Method Details
#call(severity, datetime, progname, message) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/build/logger.rb', line 58 def call(severity, datetime, progname, ) buffer = [] if @verbose buffer << time_offset_string << ": " end if progname == 'shell' and Array === buffer << format_command() else buffer << end buffer << "\n" return buffer.join end |
#chdir_string(options) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/build/logger.rb', line 37 def chdir_string() if [:chdir] " in #{[:chdir]}" else "" end end |
#format_command(arguments) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/build/logger.rb', line 45 def format_command(arguments) if arguments.last.is_a? Hash = arguments.last arguments = arguments[0...-1] else = {} end arguments = arguments.flatten.collect(&:to_s) Rainbow(arguments.join(' ')).blue + chdir_string() end |
#time_offset_string ⇒ Object
31 32 33 34 35 |
# File 'lib/build/logger.rb', line 31 def time_offset_string offset = Time.now - @start "T+#{offset.round(2).to_s.ljust(5)}" end |