lib/kiev/logger.rb in kiev-4.2.0 vs lib/kiev/logger.rb in kiev-4.3.0
- old
+ new
@@ -11,10 +11,12 @@
class Logger
extend Forwardable
def_delegators(*([:@logger] + ::Logger.instance_methods(false)))
DEFAULT_EVENT_NAME = "log"
+ LOG_ERROR = "ERROR"
+ ERROR_STATUS = 500
FORMATTER = proc do |severity, time, event_name, data|
entry =
{
application: Config.instance.app,
@@ -52,10 +54,13 @@
if data.is_a?(Hash)
entry.merge!(data)
elsif !data.nil?
entry[:message] = data.to_s
+ entry[:status] = ERROR_STATUS if data.to_s.downcase.include?(LOG_ERROR)
end
+
+ entry[:level] = LOG_ERROR if entry[:status].to_i.between?(400, 599)
# Save some disk space
entry.reject! { |_, value| value.nil? }
JSON.logstash(entry)