def init_logging(): eliot.register_exception_extractor(Exception, _add_exception_data_and_traceback) root_logger = logging.getLogger() root_logger.addHandler(EliotHandler()) root_logger.setLevel(logging.DEBUG) logging.getLogger("morepath.directive").setLevel(logging.INFO) logging.getLogger("passlib.registry").setLevel(logging.INFO) logging.getLogger("passlib.utils.compat").setLevel(logging.INFO) logging.getLogger("parso").setLevel(logging.WARN) eliot.to_file(sys.stderr, encoder=EkklesiaLogEncoder) logging.captureWarnings(True)
""" def __init__(self, code, result): """ @param code: The HTTP response code to set in the response. @type code: L{int} @param result: The value to put into the field of the response body as JSON. """ Exception.__init__(self, code, result) self.code = code self.result = result # Add response_code field to logged BadRequest: register_exception_extractor(BadRequest, lambda e: {u"code": e.code}) def makeBadRequest(code=BAD_REQUEST, **result): """ Create a new L{BadRequest} instance with the given result. """ return BadRequest(code, result) DECODING_ERROR_DESCRIPTION = cleandoc(u""" The request body could not be decoded according to the value of the Content-Type header. """) NOT_FOUND_DESCRIPTION = cleandoc(u""" The specified entity either does not exist or you are not allowed to access
# Minimum size in GiB for a provisioned IPS volume. IOPS_MIN_SIZE = 4 # http://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html # for error details: NOT_FOUND = u"InvalidVolume.NotFound" INVALID_PARAMETER_VALUE = u"InvalidParameterValue" VOLUME_ATTACHMENT_BUSY = u"busy" # Register Eliot field extractor for ClientError responses. register_exception_extractor( ClientError, lambda e: { "aws_code": e.response["Error"]["Code"], "aws_message": unicode(e.response["Error"]["Message"]), "aws_request_id": e.response["ResponseMetadata"]["RequestId"], }, ) class EBSVolumeTypes(Values): """ Constants for the different types of volumes that can be created on EBS. These are taken from the documentation at: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html :ivar STANDARD: Magnetic :ivar IO1: Provisioned IOPS (SSD)
# Minimum IOPS per second for a provisioned IOPS volume. IOPS_MIN_IOPS = 100 # Minimum size in GiB for a provisioned IPS volume. IOPS_MIN_SIZE = 4 # http://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html # for error details: NOT_FOUND = u'InvalidVolume.NotFound' INVALID_PARAMETER_VALUE = u'InvalidParameterValue' # Register Eliot field extractor for ClientError responses. register_exception_extractor( ClientError, lambda e: { "aws_code": e.response['Error']['Code'], "aws_message": unicode(e.response['Error']['Message']), "aws_request_id": e.response['ResponseMetadata']['RequestId'], } ) class EBSVolumeTypes(Values): """ Constants for the different types of volumes that can be created on EBS. These are taken from the documentation at: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html :ivar STANDARD: Magnetic :ivar IO1: Provisioned IOPS (SSD)
relpath=snapshot.relpath, author=snapshot.author.to_remote_author(), metadata=snapshot_metadata, parents_raw=parents_raw, capability=snapshot_cap, content_cap=content_cap, metadata_cap=metadata_cap, )) class TahoeWriteException(Exception): """ Something went wrong while doing a `tahoe put`. """ def __init__(self, code, body): self.code = code self.body = body def __str__(self): return '<TahoeWriteException code={} body="{}">'.format( self.code, self.body, ) # log exception caused while doing a tahoe put API register_exception_extractor(TahoeWriteException, lambda e: { "code": e.code, "body": e.body })
from functools import lru_cache from eliot import start_action, start_task, to_file, add_destinations, log_call, log_message from datetime import datetime import os import sys import traceback from eliot import register_exception_extractor register_exception_extractor(Exception, lambda e: {"traceback": traceback.format_exc()}) @lru_cache(maxsize=None) def logdir_timestamp(): return datetime.now().strftime("%y-%m-%d_%H:%M:%S") def set_file_destination(): test_name = os.environ.get('TEST_NAME') if not test_name: now = logdir_timestamp() test_name = f"apollo_run_{now}" logs_dir = '../../build/tests/apollo/logs/' test_dir = f'{logs_dir}{test_name}' test_log = f'{test_dir}/{test_name}.log' if not os.path.isdir(logs_dir): # Create logs directory if not exist os.mkdir(logs_dir)