[Notes] [Git][BuildStream/buildstream][willsalmon/log_formating] Add form log formating options



Title: GitLab

Will Salmon pushed to branch willsalmon/log_formating at BuildStream / buildstream

Commits:

1 changed file:

Changes:

  • buildstream/_frontend/widget.py
    ... ... @@ -17,6 +17,7 @@
    17 17
     #  Authors:
    
    18 18
     #        Tristan Van Berkom <tristan vanberkom codethink co uk>
    
    19 19
     import datetime
    
    20
    +import base64
    
    20 21
     import os
    
    21 22
     from collections import defaultdict, OrderedDict
    
    22 23
     from contextlib import ExitStack
    
    ... ... @@ -94,12 +95,27 @@ class FixedText(Widget):
    94 95
     
    
    95 96
     # Used to add the wallclock time this message was created at
    
    96 97
     class WallclockTime(Widget):
    
    98
    +    def __init__(self, context, content_profile, format_profile, output_format=False):
    
    99
    +        self._output_format = output_format 
    
    100
    +        super(WallclockTime, self).__init__(context, content_profile, format_profile)
    
    101
    +
    
    97 102
         def render(self, message):
    
    103
    +        if self._output_format == "base64":
    
    104
    +            return self.format_profile.fmt(base64.b64encode(message.creation_time.timestamp()))
    
    105
    +
    
    98 106
             fields = [self.content_profile.fmt("{:02d}".format(x)) for x in
    
    99 107
                       [message.creation_time.hour,
    
    100 108
                        message.creation_time.minute,
    
    101 109
                        message.creation_time.second]]
    
    102
    -        return self.format_profile.fmt(":").join(fields)
    
    110
    +
    
    111
    +        text = self.format_profile.fmt(':').join(fields)
    
    112
    +
    
    113
    +        if self._output_format=='us':
    
    114
    +            if elapsed is not None:
    
    115
    +                text += self.content_profile.fmt(".{0:06d}".format(elapsed.microseconds))
    
    116
    +            else:
    
    117
    +                text += self.content_profile.fmt(".------")
    
    118
    +        return text
    
    103 119
     
    
    104 120
     
    
    105 121
     # A widget for rendering the debugging column
    
    ... ... @@ -326,6 +342,8 @@ class LogLine(Widget):
    326 342
                 "elapsed": TimeCode(context, content_profile, format_profile, microseconds=False),
    
    327 343
                 "elapsed-us": TimeCode(context, content_profile, format_profile, microseconds=True),
    
    328 344
                 "wallclock": WallclockTime(context, content_profile, format_profile),
    
    345
    +            "wallclock-us": WallclockTime(context, content_profile, format_profile, output_format='us'),
    
    346
    +            "wallclock-base64": WallclockTime(context, content_profile, format_profile, output_format='base64'),
    
    329 347
                 "key": CacheKey(context, content_profile, format_profile, err_profile),
    
    330 348
                 "element": ElementName(context, content_profile, format_profile),
    
    331 349
                 "action": TypeName(context, content_profile, format_profile),
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]