Sha256: 7039306e488ed0c2518f14f9cfb91ed5d6a3cdf9d27015b2ac99ac7ea7c0619b
Contents?: true
Size: 910 Bytes
Versions: 5
Compression:
Stored size: 910 Bytes
Contents
require 'logger' module Protobuf module Logging def self.initialize_logger(log_target=$stdout, log_level=::Logger::INFO) @counter ||= 0 @counter = @counter + 1 @logger = Logger.new(log_target) @logger.level = log_level @logger end def self.logger defined?(@logger) ? @logger : initialize_logger end def self.logger=(new_logger) @logger = new_logger end def logger ::Protobuf::Logging.logger end def log_exception(ex) logger.error { ex.message } logger.error { ex.backtrace[0..5].join("\n") } logger.debug { ex.backtrace.join("\n") } end def log_signature @_log_signature ||= "[#{self.class == Class ? self.name : self.class.name}]" end def sign_message(message) "#{log_signature} #{message}" end end end # Inspired by [mperham](https://github.com/mperham/sidekiq)
Version data entries
5 entries across 5 versions & 1 rubygems