Module: Polyrun::Log
- Defined in:
- lib/polyrun/log.rb
Overview
Class Attribute Summary collapse
Class Method Summary collapse
- .print(msg = "") ⇒ Object
- .puts(msg = "") ⇒ Object
-
.reset_io! ⇒ Object
Clears custom sinks so
stderr/stdoutresolve to the current global $stderr / $stdout (e.g. after tests). - .warn(msg = nil) ⇒ Object
Class Attribute Details
.stderr ⇒ Object
14 15 16 |
# File 'lib/polyrun/log.rb', line 14 def stderr @stderr || $stderr end |
.stdout ⇒ Object
18 19 20 |
# File 'lib/polyrun/log.rb', line 18 def stdout @stdout || $stdout end |
Class Method Details
.print(msg = "") ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/polyrun/log.rb', line 36 def print(msg = "") io = stdout if io.respond_to?(:write) io.write(msg.to_s) elsif io.respond_to?(:print) io.print(msg.to_s) end end |
.puts(msg = "") ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/polyrun/log.rb', line 28 def puts(msg = "") if msg.nil? stdout.write("\n") else emit_line(stdout, msg) end end |
.reset_io! ⇒ Object
Clears custom sinks so stderr / stdout resolve to the current global $stderr / $stdout (e.g. after tests).
46 47 48 49 |
# File 'lib/polyrun/log.rb', line 46 def reset_io! @stderr = nil @stdout = nil end |
.warn(msg = nil) ⇒ Object
22 23 24 25 26 |
# File 'lib/polyrun/log.rb', line 22 def warn(msg = nil) return if msg.nil? emit_line(stderr, msg) end |