Module: Celluloid::Logger

Defined in:
lib/celluloid/logger.rb

Defined Under Namespace

Classes: WithBacktrace

Class Method Summary collapse

Class Method Details

.crash(string, exception) ⇒ Object

Handle a crash


58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/celluloid/logger.rb', line 58

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


38
39
40
# File 'lib/celluloid/logger.rb', line 38

def debug(string)
  Celluloid.logger.debug(string) if Celluloid.logger
end

.deprecate(message) ⇒ Object

Note a deprecation


74
75
76
77
# File 'lib/celluloid/logger.rb', line 74

def deprecate(message)
  trace = caller.join("\n\t")
  warn "DEPRECATION WARNING: #{message}\n\t#{trace}"
end

.error(string) ⇒ Object

Send an error message


53
54
55
# File 'lib/celluloid/logger.rb', line 53

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


81
82
83
84
# File 'lib/celluloid/logger.rb', line 81

def exception_handler(&block)
  @exception_handlers << block
  nil
end

.format_exception(exception) ⇒ Object

Format an exception message


87
88
89
90
91
92
93
94
# File 'lib/celluloid/logger.rb', line 87

def format_exception(exception)
  str = "#{exception.class}: #{exception.to_s}\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


43
44
45
# File 'lib/celluloid/logger.rb', line 43

def info(string)
  Celluloid.logger.info(string) if Celluloid.logger
end

.warn(string) ⇒ Object

Send a warning message


48
49
50
# File 'lib/celluloid/logger.rb', line 48

def warn(string)
  Celluloid.logger.warn(string) if Celluloid.logger
end

.with_backtrace(backtrace) {|WithBacktrace.new(backtrace)| ... } ⇒ Object

Yields:


33
34
35
# File 'lib/celluloid/logger.rb', line 33

def with_backtrace(backtrace)
  yield WithBacktrace.new(backtrace) if Celluloid.logger
end