コード例 #1
0
 def process_request(self, request):
     request.uuid = str(uuid.uuid4())
     request._logger_ctx = log.name_and_fields('django.http',
                                               uuid=request.uuid,
                                               method=request.method,
                                               path=request.path)
     request._logger_ctx.__enter__()
     log.info('Request accepted')
コード例 #2
0
    def execute(self, *args, **options):
        self.command_name = self.__class__.__module__.rsplit('.')[-1]

        fields = dict(args=', '.join(args), uuid=str(uuid.uuid4()))
        fields.update((key, value)
                      for key, value in options.items()
                      if value is not None)

        # For convenience to not make
        # from twiggy_goodies.threading import log
        # in each command
        self.logger = log

        with log.name_and_fields('command.' + self.command_name,
                                           **fields):
            log.info('Running command')
            try:
                return super(LogMixin, self).execute(*args, **options)
            except Exception:
                log.trace().error('Unhandled exception')
                raise