Module: Protobuf::Logger::LogMethods
- Included in:
- Protobuf::Lifecycle, Rpc::Client, Rpc::Connectors::Base, Rpc::Connectors::Http, Rpc::Connectors::Socket, Rpc::Connectors::Zmq, Rpc::Http::Server, Rpc::Middleware::ExceptionHandler, Rpc::Middleware::RequestDecoder, Rpc::Middleware::ResponseEncoder, Rpc::Service, Rpc::ServiceDirectory, Rpc::ServiceDispatcher, Rpc::Socket::Server, Rpc::Socket::Worker, Rpc::Zmq::Util, Rpc::ZmqRunner
- Defined in:
- lib/protobuf/logger.rb
Overview
LogMethods module for log method including, e.g.:
class MyClass include Protobuf::Logger::LogMethods ... end
Produce a module to allow "include" in other classes to avoid cluttering the namespace of the including class with the other methods defined above
Class Method Summary collapse
-
.included(base) ⇒ Object
When included, also extend the LogMethods module for class access.
Instance Method Summary collapse
-
#log_exception(ex) ⇒ Object
We often want to log an exception, so let's make that a core concern of the logger.
- #log_signature ⇒ Object
- #sign_message(message) ⇒ Object
Class Method Details
.included(base) ⇒ Object
When included, also extend the LogMethods module for class access.
62 63 64 |
# File 'lib/protobuf/logger.rb', line 62 def self.included(base) base.extend(LogMethods) end |
Instance Method Details
#log_exception(ex) ⇒ Object
We often want to log an exception, so let's make that a core concern of the logger.
69 70 71 72 73 |
# File 'lib/protobuf/logger.rb', line 69 def log_exception(ex) log_error { ex. } log_error { ex.backtrace[0..5].join("\n") } log_debug { ex.backtrace.join("\n") } end |
#log_signature ⇒ Object
75 76 77 |
# File 'lib/protobuf/logger.rb', line 75 def log_signature @_log_signature ||= "[#{self.class == Class ? self.name : self.class.name}]" end |
#sign_message(message) ⇒ Object
79 80 81 |
# File 'lib/protobuf/logger.rb', line 79 def () "#{log_signature} #{}" end |