Skip to content
Snippets Groups Projects
Commit 50735328 authored by William Salmon's avatar William Salmon
Browse files

Add form log formating options

The 'wallclock-us' is a option that we thought we already had.

The base64 option is not human redable but should be quicker and dose
not lose infomation converting back and forth from human redable.
parent 7256bb0c
No related branches found
No related tags found
No related merge requests found
Pipeline #45425335 failed
......@@ -17,6 +17,7 @@
# Authors:
# Tristan Van Berkom <tristan.vanberkom@codethink.co.uk>
import datetime
import base64
import os
from collections import defaultdict, OrderedDict
from contextlib import ExitStack
......@@ -94,12 +95,27 @@ class FixedText(Widget):
# Used to add the wallclock time this message was created at
class WallclockTime(Widget):
def __init__(self, context, content_profile, format_profile, output_format=False):
self._output_format = output_format
super(WallclockTime, self).__init__(context, content_profile, format_profile)
def render(self, message):
if self._output_format == "base64":
return self.format_profile.fmt(base64.b64encode(message.creation_time.timestamp()))
fields = [self.content_profile.fmt("{:02d}".format(x)) for x in
[message.creation_time.hour,
message.creation_time.minute,
message.creation_time.second]]
return self.format_profile.fmt(":").join(fields)
text = self.format_profile.fmt(':').join(fields)
if self._output_format=='us':
if elapsed is not None:
text += self.content_profile.fmt(".{0:06d}".format(elapsed.microseconds))
else:
text += self.content_profile.fmt(".------")
return text
# A widget for rendering the debugging column
......@@ -326,6 +342,8 @@ class LogLine(Widget):
"elapsed": TimeCode(context, content_profile, format_profile, microseconds=False),
"elapsed-us": TimeCode(context, content_profile, format_profile, microseconds=True),
"wallclock": WallclockTime(context, content_profile, format_profile),
"wallclock-us": WallclockTime(context, content_profile, format_profile, output_format='us'),
"wallclock-base64": WallclockTime(context, content_profile, format_profile, output_format='base64'),
"key": CacheKey(context, content_profile, format_profile, err_profile),
"element": ElementName(context, content_profile, format_profile),
"action": TypeName(context, content_profile, format_profile),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment