Sha256: 87e2f27748c23918f57b626dfffd972e6d670bf807ea1dc7123faebf1cbbde69
Contents?: true
Size: 1.05 KB
Versions: 10
Compression:
Stored size: 1.05 KB
Contents
# 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 def log_debug(message, additional = {}) log_pattern('debug', additional.merge(message: message)) end private def log_pattern(level, log_hash) log = default_log(level.upcase).merge(log_hash) Rails.logger.send(level, 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
Version data entries
10 entries across 10 versions & 1 rubygems