# frozen_string_literal: true module LogToolbox module LogSimple class << self def log_error(message, additional = {}) log_pattern('error', additional.merge(message: message)) end def log_warn(message, additional = {}) log_pattern('warn', additional.merge(message: message)) end def log_info(message, additional = {}) log_pattern('info', additional.merge(message: message)) end private def log_pattern(level, log_hash) log = default_log(level.upcase).merge(log_hash) puts(normalize_hash(log)) end def default_log(level) { event_at: I18n.l(Time.now, format: :timestamp), level: level, service_name: LogUtil.system_service_name, version: LogUtil.system_version } end def normalize_hash(hash) hash.stringify_keys.to_json end end end end