Sha256: aa121bd6961c230cb6a2ab486b264efac2b5695505bd2dbe746d97456248583d
Contents?: true
Size: 723 Bytes
Versions: 1
Compression:
Stored size: 723 Bytes
Contents
# frozen_string_literal: true require 'logger' module MrLogaLoga # == Description # # This class separates message and contextual data from args class LoggerData class << self def build(*args, &block) args = block ? block.call : args msg, context = args if msg.nil? [nil, as_hash(context)] elsif context.nil? msg.is_a?(Hash) ? [nil, msg] : [msg, {}] else [msg, as_hash(context)] end end private def as_hash(data) if data.is_a?(Hash) || data.respond_to?(:to_hash) data elsif !data.nil? { context: data } else {} end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mr_loga_loga-0.2.0 | lib/mr_loga_loga/logger_data.rb |