Sha256: af00a9d9a9f3de4b3b5bf11d0861104dcedf60b5d422489be4033e6aba96b402
Contents?: true
Size: 988 Bytes
Versions: 3
Compression:
Stored size: 988 Bytes
Contents
require 'inflecto' require 'logger' require 'json' require_relative 'logasm/adapters' require_relative 'logasm/utils' require_relative 'logasm/null_logger' 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
logasm-0.2.5 | lib/logasm.rb |
logasm-0.2.4 | lib/logasm.rb |
logasm-0.2.3 | lib/logasm.rb |