Module: Celluloid::Internals::Logger
- Defined in:
- lib/celluloid/internals/logger.rb
Defined Under Namespace
Classes: WithBacktrace
Class Method Summary collapse
-
.crash(string, exception) ⇒ Object
Handle a crash.
-
.debug(string) ⇒ Object
Send a debug message.
-
.deprecate(message) ⇒ Object
Note a deprecation.
-
.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.
- .with_backtrace(backtrace) {|WithBacktrace.new(backtrace)| ... } ⇒ Object
Class Method Details
.crash(string, exception) ⇒ Object
Handle a crash
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/celluloid/internals/logger.rb', line 59 def crash(string, exception) if Celluloid.log_actor_crashes string << "\n" << format_exception(exception) error string end @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
39 40 41 |
# File 'lib/celluloid/internals/logger.rb', line 39 def debug(string) Celluloid.logger.debug(string) if Celluloid.logger && $CELLULOID_DEBUG end |
.deprecate(message) ⇒ Object
Note a deprecation
75 76 77 78 |
# File 'lib/celluloid/internals/logger.rb', line 75 def deprecate() trace = caller.join("\n\t") warn "DEPRECATION WARNING: #{}\n\t#{trace}" end |
.error(string) ⇒ Object
Send an error message
54 55 56 |
# File 'lib/celluloid/internals/logger.rb', line 54 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
82 83 84 85 |
# File 'lib/celluloid/internals/logger.rb', line 82 def exception_handler(&block) @exception_handlers << block nil end |
.format_exception(exception) ⇒ Object
Format an exception message
88 89 90 91 92 93 94 95 |
# File 'lib/celluloid/internals/logger.rb', line 88 def format_exception(exception) str = "#{exception.class}: #{exception}\n\t" if exception.backtrace str << exception.backtrace.join("\n\t") else str << "EMPTY BACKTRACE\n\t" end end |
.info(string) ⇒ Object
Send a info message
44 45 46 |
# File 'lib/celluloid/internals/logger.rb', line 44 def info(string) Celluloid.logger.info(string) if Celluloid.logger end |
.warn(string) ⇒ Object
Send a warning message
49 50 51 |
# File 'lib/celluloid/internals/logger.rb', line 49 def warn(string) Celluloid.logger.warn(string) if Celluloid.logger end |
.with_backtrace(backtrace) {|WithBacktrace.new(backtrace)| ... } ⇒ Object
34 35 36 |
# File 'lib/celluloid/internals/logger.rb', line 34 def with_backtrace(backtrace) yield WithBacktrace.new(backtrace) if Celluloid.logger end |