Sha256: 0b089b29cae616613e3ca0ba4e539a0551be7fe568fc8d264b07556cc56821ef
Contents?: true
Size: 950 Bytes
Versions: 1
Compression:
Stored size: 950 Bytes
Contents
require 'inflecto' require 'logger' require 'json' require_relative 'logasm/adapters' require_relative 'logasm/utils' 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
logasm-0.2.2 | lib/logasm.rb |