Refactor: call getfqdn() once per call of replace_placeholders()

(cherry picked from commit 294f06b565)
This commit is contained in:
Gregor Kleen 2017-12-12 12:44:17 +01:00 committed by Thomas Waldmann
parent dbf8d582f9
commit 96675e06c8
1 changed files with 3 additions and 2 deletions

View File

@ -661,10 +661,11 @@ def format_line(format, data):
def replace_placeholders(text):
"""Replace placeholders in text with their values."""
current_time = datetime.now()
fqdn = socket.getfqdn()
data = {
'pid': os.getpid(),
'fqdn': socket.getfqdn(),
'reverse-fqdn': '.'.join(reversed(socket.getfqdn().split('.'))),
'fqdn': fqdn,
'reverse-fqdn': '.'.join(reversed(fqdn.split('.'))),
'hostname': socket.gethostname(),
'now': DatetimeWrapper(current_time.now()),
'utcnow': DatetimeWrapper(current_time.utcnow()),