Class: Abstractive::Actor
- Inherits:
-
Object
- Object
- Abstractive::Actor
- Includes:
- Celluloid
- Defined in:
- lib/abstractive/actor.rb
Instance Method Summary collapse
- #console(message, options = {}) ⇒ Object
- #debug(message) ⇒ Object
- #exception(ex, *args) ⇒ Object
- #mark ⇒ Object
- #plain_output(message) ⇒ Object
- #pretty_output(object) ⇒ Object
Instance Method Details
#console(message, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/abstractive/actor.rb', line 8 def console(, ={}) if @logger @logger.console(, .merge(local: true)) else plain_output("#{mark}#{}") end rescue plain_output("#{mark}#{}") end |
#debug(message) ⇒ Object
18 19 20 |
# File 'lib/abstractive/actor.rb', line 18 def debug() console(, level: :debug) end |
#exception(ex, *args) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/abstractive/actor.rb', line 22 def exception(ex, *args) return @logger.exception(ex, *args) if @logger plain_output("(#{ex.class}) #{ex.}: #{args.first}") rescue plain_output("(#{ex.class}) #{ex.}: #{args.first}") ensure plain_output("(#{ex.class}) #{ex.}: #{args.first}") end |
#mark ⇒ Object
41 42 43 44 45 |
# File 'lib/abstractive/actor.rb', line 41 def mark if @mark == true "#{self.class.name} > " end end |
#plain_output(message) ⇒ Object
31 32 33 34 35 |
# File 'lib/abstractive/actor.rb', line 31 def plain_output() = "*, [#{Time.now.strftime('%FT%T.%L')}] #{mark}#{}" STDERR.puts STDOUT.puts end |
#pretty_output(object) ⇒ Object
37 38 39 |
# File 'lib/abstractive/actor.rb', line 37 def pretty_output object puts JSON.pretty_generate(object) end |