Class: HonestPubsub::Logger
- Inherits:
-
Object
- Object
- HonestPubsub::Logger
- Defined in:
- lib/honest_pubsub/logger.rb
Instance Method Summary collapse
- #failed_publish(routing_key, properties, message) ⇒ Object
-
#initialize(enable_publish_logging = true) ⇒ Logger
constructor
A new instance of Logger.
- #log_publish(routing_key, message) ⇒ Object
- #log_receive(routing_key, message) ⇒ Object
- #log_service(service_name, log_level, message) ⇒ Object
- #teardown ⇒ Object
Constructor Details
#initialize(enable_publish_logging = true) ⇒ Logger
Returns a new instance of Logger.
4 5 6 7 |
# File 'lib/honest_pubsub/logger.rb', line 4 def initialize(enable_publish_logging = true) @enabled = HonestPubsub::Configuration.configuration[:logger][:enabled] @enabled = enable_publish_logging if @enabled.nil? end |
Instance Method Details
#failed_publish(routing_key, properties, message) ⇒ Object
24 25 26 27 |
# File 'lib/honest_pubsub/logger.rb', line 24 def failed_publish(routing_key, properties, ) = ["FAILED_SEND", [:ts], [:pub], [:v], routing_key] logger.tagged() { logger.warn [:payload].as_json } end |
#log_publish(routing_key, message) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/honest_pubsub/logger.rb', line 9 def log_publish(routing_key, ) return unless @enabled # generate tags needed = ["PUBLISH", [:ts], [:pub], [:v], routing_key] # FIX!!! -thl # Could logging like this be too slow? # Or should it be threaded? # We'll need to benchmark, as we don't want this to get too slow. logger.tagged() { logger.warn [:payload].as_json } # TODO: -thl # Log it into mongo as well? end |
#log_receive(routing_key, message) ⇒ Object
29 30 31 32 |
# File 'lib/honest_pubsub/logger.rb', line 29 def log_receive(routing_key, ) = ["RECEIVED", [:ts], [:pub], [:v], routing_key, Process::pid] logger.tagged() { logger.warn [:payload].as_json } end |
#log_service(service_name, log_level, message) ⇒ Object
34 35 36 37 38 |
# File 'lib/honest_pubsub/logger.rb', line 34 def log_service(service_name, log_level, ) = ["SERVICE", service_name, Process::pid] log_method = log_level.to_sym.to_proc logger.tagged() { log_method.call(logger) { .as_json } } end |
#teardown ⇒ Object
40 41 42 |
# File 'lib/honest_pubsub/logger.rb', line 40 def teardown logger.close end |