module StackifyRubyAPM::Log

@api private This module will format the process logs perform between the Agent and Web App

Constants

PREFIX

Public Instance Methods

debug(msg, *args, &block) click to toggle source
# File lib/stackify_apm/log.rb, line 9
def debug(msg, *args, &block)
  log(:debug, msg, *args, &block)
end
error(msg, *args, &block) click to toggle source
# File lib/stackify_apm/log.rb, line 21
def error(msg, *args, &block)
  log(:error, msg, *args, &block)
end
fatal(msg, *args, &block) click to toggle source
# File lib/stackify_apm/log.rb, line 25
def fatal(msg, *args, &block)
  log(:fatal, msg, *args, &block)
end
info(msg, *args, &block) click to toggle source
# File lib/stackify_apm/log.rb, line 13
def info(msg, *args, &block)
  log(:info, msg, *args, &block)
end
log(lvl, msg, *args) click to toggle source
# File lib/stackify_apm/log.rb, line 29
def log(lvl, msg, *args)
  return unless logger

  formatted_msg = prepend_prefix(format(msg.to_s, *args))

  return logger.send(lvl, formatted_msg) unless block_given?

  # TODO: dont evaluate block if level is higher
  logger.send(lvl, "#{formatted_msg}\n#{yield}")
end
warn(msg, *args, &block) click to toggle source
# File lib/stackify_apm/log.rb, line 17
def warn(msg, *args, &block)
  log(:warn, msg, *args, &block)
end

Private Instance Methods

logger() click to toggle source
# File lib/stackify_apm/log.rb, line 46
def logger
  return false unless (config = instance_variable_get(:@config))
  config.logger
end
prepend_prefix(str) click to toggle source
# File lib/stackify_apm/log.rb, line 42
def prepend_prefix(str)
  "#{PREFIX}#{str}"
end