コード例 #1
0
ファイル: index.py プロジェクト: vickatte/jazz
def handler(event, context):
    # initialize logger module
    logger = Logger(event, context)
   
    # Load config handler   
    config = Config(context)

    ## ==== Sample code to fetch environment specific configurations ====
    # myconfig = config.get_config('default') === "default" is the section over here
    # logger.info ('One of the environment configuration: config_key => ' + myconfig['config_key'])

    ## ==== Log message samples ====
    # logger.error('Runtime errors or unexpected conditions.')
    # logger.warn('Runtime situations that are undesirable, but not wrong')
    # logger.info('Interesting runtime events eg. connection established)')
    # logger.verbose('Generally speaking, most log lines should be verbose.')
    # logger.debug('Detailed information on the flow through the system.')

    myconfig = config.get_config('default')

    logger.info('Sample response for function1.')
    return {
        "message": "Your function executed successfully!",
        "event": event,
        "myconfig": myconfig['config_key']
    }
コード例 #2
0
ファイル: index.py プロジェクト: vickatte/jazz
def handler(event, context):
    try:
        # initialize logger module
        logger = Logger(event, context)

        # Load config handler.
        config = Config(event)

        ## ==== Sample code to fetch environment specific configurations ====
        # myconfig = config.get_config('default')
        # logger.info ('One of the environment configuration: config_key => ' + myconfig['config_key'])

        ## ==== Log message samples ====
        # logger.error('Runtime errors or unexpected conditions.')
        # logger.warn('Runtime situations that are undesirable, but not wrong')
        # logger.info('Interesting runtime events eg. connection established)')
        # logger.verbose('Generally speaking, most log lines should be verbose.')
        # logger.debug('Detailed information on the flow through the system.')

        # This is the happy path
        data = {
            'key': 'value'
        }

        response = ""
        if 'method' in event:
            if event['method'] == "POST":
                # Handle Post response here
                logger.info('Sample log inside POST')
                response = CustomResponse(data, event['body']).get_json()
            else:
                # Handle Get/other response here.
                logger.info('Sample log inside GET')
                response = CustomResponse(data, event['query']).get_json()
        return response
    except Exception as e:
        # Exception Handling
        exception_type = e.__class__.__name__

        # Create a JSON string here
        api_exception_json = CustomErrors.throwInternalServerError(
            str(e))
        raise LambdaException(api_exception_json)
コード例 #3
0
def handler(event, context):
    try:

        # initialze logger module
        logger = Logger(event, context)

        # Load config handler.
        config = Config(event)

        logger.error('Runtime errors or unexpected conditions.')
        logger.warn('Runtime situations that are undesirable, but not wrong')
        logger.info('Interesting runtime events eg. connection established)')
        logger.verbose('Generally speaking, most log lines should be verbose.')
        logger.debug('Detailed information on the flow through the system.')

        # This is the happy path
        data = {
            'key': 'value'
        }

        response = ""
        if 'method' in event:
            if event['method'] == "POST":
                # Handle Post response here
                response = CustomResponse(data, event['body']).get_json()
            else:
                # Handle Get/other response here.
                response = CustomResponse(data, event['query']).get_json()
        return response
    except Exception as e:
        # Exception Handling
        exception_type = e.__class__.__name__
        exception_message = e.message

        # Create a JSON string here
        api_exception_json = CustomErrors.throwInternalServerError(
            exception_message)
        raise LambdaException(api_exception_json)
コード例 #4
0
    def __init__(self):
        self.pg_dump_path = "/opt/PostgreSQL/9.6/bin/pg_dump"

        # initializing DB Configuration Handler
        self.db_config_handler = DBConfiguration()

        # fetching DB configuration
        self.db_configuration_dict = self.db_config_handler

        # initialize logging parameters
        self.log_params = {
            "error": {
                "file_name": "error.log",
                "log_dir": settings.LOG_DIR,
                "stream_handler": None,
                "file_handler": True
            }
        }

        # initializing scp handler
        self.scp_handler = SCPHandler(
            **settings.REMOTE_SERVER_CREDENTIAL["remote_vps"])

        self.error_logger = Logger(**self.log_params["error"])
コード例 #5
0
def main():
    config = configparser.ConfigParser()
    config.read('config.ini')
    config = config['default']

    make_logging_directory_if_not_exists(directory=config.get('logging_path'))

    logger = Logger(
        fpath=os.path.join(config.get('logging_path'), 'log'),
        rotation_interval=config.get('log_rotation_interval'),
        rotation_frequency=config.getint('log_rotation_frequency'),
    )

    buffer = TimedStringBuffer(
        logger = logger, 
        threshold = config.getfloat('sentence_max_delta_seconds'),
        render_backspaces = config.getboolean('render_backspaces')
    )
    keyboard.on_press(callback=buffer.add)

    try:
        keyboard.wait()
    except KeyboardInterrupt:
        sys.exit(0)