Sha256: 9ffbb6d605e52cb7d1a97fa3decb9bf43cf118c6194335a21dc32b491e85af3e
Contents?: true
Size: 1.56 KB
Versions: 3
Compression:
Stored size: 1.56 KB
Contents
module Quandl module Command class Task module Logging extend ActiveSupport::Concern included do before_execute :start_request_timer before_execute :configure_logger after_execute :log_request_time attr_accessor :request_timer end def start_request_timer self.request_timer = Time.now end def configure_logger @stderr_logger = initialize_logger(config.stderr) if config.stderr.present? @stdout_logger = initialize_logger(config.stdout) if config.stdout.present? end def initialize_logger(path) l = ::Logger.new( path, 2, 52428800 ) l.formatter = proc do |severity, datetime, progname, msg| "# [#{datetime.strftime("%Y-%m-%d %H:%M:%S")}]\n#{msg}" end l end def log_request_time debug("# Started: #{request_timer}. Finished: #{Time.now}. Elapsed: #{request_timer.elapsed_ms}") end def summarize(item) return summarize_hash(item) if item.kind_of?(Hash) item end def summarize_hash(item) item.collect do |k,v| next "#{k}: '#{v}'" if v.kind_of?(String) "#{k}: #{v}" end.join(', ') end def table(*args) Array(args).flatten.join(" | ") end def info(*args) logger.info(*args) end def debug(*args) args.each{|a| logger.debug("# #{a}") } if verbose? end def error(*args) stderr_logger.error(*args) end def fatal(*args) stderr_logger.fatal("FATAL: #{args.join(" ")}") end def logger @stdout_logger ||= Quandl::Logger end def stderr_logger @stderr_logger ||= Quandl::Logger end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
quandl-0.3.4 | lib/quandl/command/task/logging.rb |
quandl-0.3.3 | lib/quandl/command/task/logging.rb |
quandl-0.3.0 | lib/quandl/command/task/logging.rb |