Module: XCCache::UI
- Extended by:
- Config::Mixin
- Defined in:
- lib/xccache/core/log.rb
Class Attribute Summary collapse
-
.indent ⇒ Object
Returns the value of attribute indent.
Class Method Summary collapse
- .error(message) ⇒ Object
- .error!(message) ⇒ Object
- .info(message) ⇒ Object
- .message(message) ⇒ Object
- .puts(message) ⇒ Object
- .section(title, timing: false) ⇒ Object
- .warn(message) ⇒ Object
Methods included from Config::Mixin
Class Attribute Details
.indent ⇒ Object
Returns the value of attribute indent.
10 11 12 |
# File 'lib/xccache/core/log.rb', line 10 def indent @indent end |
Class Method Details
.error(message) ⇒ Object
42 43 44 |
# File 'lib/xccache/core/log.rb', line 42 def error() UI.puts("[ERROR] #{}".red) end |
.error!(message) ⇒ Object
46 47 48 49 |
# File 'lib/xccache/core/log.rb', line 46 def error!() error() raise GeneralError, end |
.message(message) ⇒ Object
30 31 32 |
# File 'lib/xccache/core/log.rb', line 30 def () UI.puts() if config.verbose? end |
.puts(message) ⇒ Object
51 52 53 |
# File 'lib/xccache/core/log.rb', line 51 def puts() $stdout.puts("#{' ' * self.indent}#{}") end |
.section(title, timing: false) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/xccache/core/log.rb', line 12 def section(title, timing: false) start = Time.new if timing UI.puts(title) self.indent += 2 res = yield if block_given? self.indent -= 2 if timing duration = (Time.new - start).to_i duration = if duration < 60 then "#{duration}s" elsif duration < 60 * 60 then "#{duration / 60}m" else "#{duration / 3600}h" end UI.puts("-> Finished: #{title.dark} (#{duration})") end res end |