Sha256: c560e3b71a60c76c4ecf3a17faa9240379d64f95b0cfd2ff3102cf31d0081af2
Contents?: true
Size: 903 Bytes
Versions: 2
Compression:
Stored size: 903 Bytes
Contents
require 'inflecto' require 'logger' require_relative 'logasm/adapters' class Logasm def self.build(service_name, loggers_config) loggers_config ||= {stdout: nil} adapters = loggers_config.map do |type, arguments| Adapters.get(type.to_s, service_name, arguments || {}) end new(adapters) end def initialize(adapters) @adapters = adapters end def debug(*args) log :debug, *args end def info(*args) log :info, *args end def warn(*args) log :warn, *args end def error(*args) log :error, *args end def fatal(*args) log :fatal, *args end private def log(level, *args) data = parse_log_data(*args) @adapters.each do |adapter| adapter.log(level, data) end end def parse_log_data(message, metadata = {}) return message if message.is_a?(Hash) (metadata || {}).merge(message: message) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
logasm-0.2.1 | lib/logasm.rb |
logasm-0.2.0 | lib/logasm.rb |