lib/appsignal.rb in appsignal-2.0.3 vs lib/appsignal.rb in appsignal-2.0.4
- old
+ new
@@ -224,17 +224,18 @@
end
def logger
@logger ||= Logger.new(in_memory_log).tap do |l|
l.level = Logger::INFO
- l.formatter = log_formatter
+ l.formatter = log_formatter("appsignal")
end
end
- def log_formatter
+ def log_formatter(prefix = nil)
+ pre = "#{prefix}: " if prefix
proc do |severity, datetime, progname, msg|
- "[#{datetime.strftime('%Y-%m-%dT%H:%M:%S')} (process) ##{Process.pid}][#{severity}] #{msg}\n"
+ "[#{datetime.strftime('%Y-%m-%dT%H:%M:%S')} (process) ##{Process.pid}][#{severity}] #{pre}#{msg}\n"
end
end
def start_logger(path_arg = nil)
if config && config[:log] == "file" && config.log_file_path
@@ -288,21 +289,19 @@
private
def start_stdout_logger
@logger = Logger.new($stdout)
- @logger.formatter = lambda do |severity, datetime, progname, msg|
- "appsignal: #{msg}\n"
- end
+ logger.formatter = log_formatter("appsignal")
end
def start_file_logger(path)
@logger = Logger.new(path)
- @logger.formatter = log_formatter
+ logger.formatter = log_formatter
rescue SystemCallError => error
start_stdout_logger
- logger.warn "appsignal: Unable to start logger with log path '#{path}'."
- logger.warn "appsignal: #{error}"
+ logger.warn "Unable to start logger with log path '#{path}'."
+ logger.warn error
end
end
end
require 'appsignal/utils'