Module: Celluloid::Logger
- Defined in:
- lib/celluloid/logger.rb
Class Method Summary collapse
-
.crash(string, exception) ⇒ Object
Handle a crash.
-
.debug(string) ⇒ Object
Send a debug message.
-
.error(string) ⇒ Object
Send an error message.
-
.exception_handler(&block) ⇒ Object
Define an exception handler NOTE: These should be defined at application start time.
-
.format_exception(exception) ⇒ Object
Format an exception message.
-
.info(string) ⇒ Object
Send a info message.
-
.warn(string) ⇒ Object
Send a warning message.
Class Method Details
.crash(string, exception) ⇒ Object
Handle a crash
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/celluloid/logger.rb', line 27 def crash(string, exception) string << "\n" << format_exception(exception) error string @exception_handlers.each do |handler| begin handler.call(exception) rescue => ex error "EXCEPTION HANDLER CRASHED:\n" << format_exception(ex) end end end |
.debug(string) ⇒ Object
Send a debug message
7 8 9 |
# File 'lib/celluloid/logger.rb', line 7 def debug(string) Celluloid.logger.debug(string) if Celluloid.logger end |
.error(string) ⇒ Object
Send an error message
22 23 24 |
# File 'lib/celluloid/logger.rb', line 22 def error(string) Celluloid.logger.error(string) if Celluloid.logger end |
.exception_handler(&block) ⇒ Object
Define an exception handler NOTE: These should be defined at application start time
48 49 50 51 |
# File 'lib/celluloid/logger.rb', line 48 def exception_handler(&block) @exception_handlers << block nil end |
.format_exception(exception) ⇒ Object
Format an exception message
41 42 43 44 |
# File 'lib/celluloid/logger.rb', line 41 def format_exception(exception) str = "#{exception.class}: #{exception.to_s}\n" str << exception.backtrace.join("\n") end |