summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Vondra <jan.vondra@ultimum.io>2020-07-11 16:58:29 +0200
committerJan Vondra <jan.vondra@ultimum.io>2020-07-11 16:01:32 +0000
commit6f9b434bb3bc4014d5041f6b1a1da858e3d4aa77 (patch)
treef8f9f4afc3e071c78d97552f80682756b00fcd59
parent0a2dc7096bcdb83431e0c6e9b73800540596956e (diff)
downloadoslo-log-6f9b434bb3bc4014d5041f6b1a1da858e3d4aa77.tar.gz
Added uwsgi_name information into fluentFormatter event message
When running under uwsgi a new key "uwsgi_name" is added to log events when using FluentFormatter that could be used for further analysis. It's value is taken from uwsgi configuration upon formatter initialization. Change-Id: I158409677523978246c26bf1168f323974d817a5 Closes-Bug: 1887232
-rw-r--r--oslo_log/formatters.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/oslo_log/formatters.py b/oslo_log/formatters.py
index 8ca3f7e..a0a14b5 100644
--- a/oslo_log/formatters.py
+++ b/oslo_log/formatters.py
@@ -290,6 +290,13 @@ class FluentFormatter(logging.Formatter):
except socket.error:
self.hostname = None
self.cmdline = " ".join(sys.argv)
+ try:
+ # check if running under uwsgi
+ import uwsgi
+ svc_name = uwsgi.opt.get("name")
+ self.uwsgi_name = svc_name
+ except Exception:
+ self.uwsgi_name = None
def formatException(self, exc_info, strip_newlines=True):
try:
@@ -351,6 +358,9 @@ class FluentFormatter(logging.Formatter):
if record.exc_info:
message['traceback'] = self.formatException(record.exc_info)
+ if self.uwsgi_name:
+ message["uwsgi_name"] = self.uwsgi_name
+
return message