Sha256: 4ae5692b409aa421960bb8a4d99794492fff37bd07fc6fd62ad7d441e6a47822
Contents?: true
Size: 789 Bytes
Versions: 1
Compression:
Stored size: 789 Bytes
Contents
require 'logger' module GetaroundUtils; end module GetaroundUtils::Mixins; end module GetaroundUtils::Mixins::Loggable def class_name @class_name ||= is_a?(Class) ? name : self.class.name end def base_append_infos_to_loggable(payload) payload[:origin] = class_name return unless respond_to?(:append_infos_to_loggable) append_infos_to_loggable(payload) end def base_loggable_logger @base_loggable_logger ||= if respond_to?(:logger) logger elsif defined?(Rails) Rails.logger else Logger.new(STDOUT) end end def loggable(severity, payload) extra_infos = {} base_append_infos_to_loggable(extra_infos) payload = payload.merge(extra_infos).compact base_loggable_logger.send(severity.to_sym, payload) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
getaround_utils-0.1.7 | lib/getaround_utils/mixins/loggable.rb |