/usr/lib/ruby/vendor_ruby/celluloid/logger.rb is in ruby-celluloid 0.16.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | module Celluloid
module Logger
class WithBacktrace
def initialize(backtrace)
@backtrace = backtrace
end
def debug(string)
Celluloid.logger.debug(decorate(string))
end
def info(string)
Celluloid.logger.info(decorate(string))
end
def warn(string)
Celluloid.logger.warn(decorate(string))
end
def error(string)
Celluloid.logger.error(decorate(string))
end
def decorate(string)
[string, @backtrace].join("\n\t")
end
end
@exception_handlers = []
module_function
def with_backtrace(backtrace)
yield WithBacktrace.new(backtrace) if Celluloid.logger
end
# Send a debug message
def debug(string)
Celluloid.logger.debug(string) if Celluloid.logger
end
# Send a info message
def info(string)
Celluloid.logger.info(string) if Celluloid.logger
end
# Send a warning message
def warn(string)
Celluloid.logger.warn(string) if Celluloid.logger
end
# Send an error message
def error(string)
Celluloid.logger.error(string) if Celluloid.logger
end
# Handle a crash
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
# Note a deprecation
def deprecate(message)
trace = caller.join("\n\t")
warn "DEPRECATION WARNING: #{message}\n\t#{trace}"
end
# Define an exception handler
# NOTE: These should be defined at application start time
def exception_handler(&block)
@exception_handlers << block
nil
end
# Format an exception message
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
end
end
|