summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-07-20 16:31:14 -0700
committerStan Hu <stanhu@gmail.com>2018-07-20 16:31:14 -0700
commit48ea89af121bdf627fc08673f9203e5f05dc0776 (patch)
tree52ab1338ae9a626158189bd01e9ba70c1497aada /lib
parent33c319508e3e554db6c6d673cb0f564262133e06 (diff)
parent4271f448c85f6a3dc50728a4b77d7d57474bac6f (diff)
downloadgitlab-ce-48ea89af121bdf627fc08673f9203e5f05dc0776.tar.gz
Merge branch 'master' into sh-support-bitbucket-server-import
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/json_logger.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/gitlab/json_logger.rb b/lib/gitlab/json_logger.rb
new file mode 100644
index 00000000000..28e258196ca
--- /dev/null
+++ b/lib/gitlab/json_logger.rb
@@ -0,0 +1,22 @@
+module Gitlab
+ class JsonLogger < ::Gitlab::Logger
+ def self.file_name_noext
+ raise NotImplementedError
+ end
+
+ def format_message(severity, timestamp, progname, message)
+ data = {}
+ data[:severity] = severity
+ data[:time] = timestamp.utc.iso8601(3)
+
+ case message
+ when String
+ data[:message] = message
+ when Hash
+ data.merge!(message)
+ end
+
+ data.to_json + "\n"
+ end
+ end
+end