lambo.py
def bind(self, handler):
        """
        Decorate Lambda handler to attach logger to AWS request.

        :Example:

        >>> logger = lambo.getLogger(__name__)
        >>>
        >>> @logger.attach
        ... def handler(event, context):
        ...     logger.info('Hello, world!')
        ...     return {'ok': True}
        ...
        >>> handler({'fizz': 'buzz'})
        >>> # => INFO RequestId: {awsRequestId} EVENT {"fizz": "buzz"}
        >>> # => INFO RequestId: {awsRequestId} Hello, world!
        >>> # => INFO RequestId: {awsRequestId} RETURN {"ok": True}
        """
        def wrapper(event=None, context=None):
            try:
                params = {'default': str}
                if LOG_JSON_INDENT:
                    params.update(indent=int(LOG_JSON_INDENT))
                self.addContext(context)
                self.info('EVENT %s', json.dumps(event, **params))
                result = handler(event, context)
                self.info('RETURN %s', json.dumps(result, **params))
                return result
            finally:
                self.dropContext()
        return wrapper

        Decorate Lambda handler to attach logger to AWS request.

        :Example:

        >>> logger = lambo.getLogger(__name__)
        >>>
        >>> @logger.attach
        ... def handler(event, context):
        ...     logger.info('Hello, world!')
        ...     return {'ok': True}
        ...
        >>> handler({'fizz': 'buzz'})
        >>> # => INFO RequestId: {awsRequestId} EVENT {"fizz": "buzz"}
        >>> # => INFO RequestId: {awsRequestId} Hello, world!
        >>> # => INFO RequestId: {awsRequestId} RETURN {"ok": True}
        
Decorate Lambda handler to attach logger to AWS request.
Decorate Lambda handler to attach logger to AWS request .
def bind(self, handler):
        def wrapper(event=None, context=None):
            try:
                params = {'default': str}
                if LOG_JSON_INDENT:
                    params.update(indent=int(LOG_JSON_INDENT))
                self.addContext(context)
                self.info('EVENT %s', json.dumps(event, **params))
                result = handler(event, context)
                self.info('RETURN %s', json.dumps(result, **params))
                return result
            finally:
                self.dropContext()
        return wrapper
def bind ( self , handler ) : def wrapper ( event = None , context = None ) : try : params = { 'default' : str } if LOG_JSON_INDENT : params . update ( indent = int ( LOG_JSON_INDENT ) ) self . addContext ( context ) self . info ( 'EVENT %s' , json . dumps ( event , ** params ) ) result = handler ( event , context ) self . info ( 'RETURN %s' , json . dumps ( result , ** params ) ) return result finally : self . dropContext ( ) return wrapper
Decorate Lambda handler to attach logger to AWS request.
Decorate Lambda handler to attach logger to AWS request .
"""
        Decorate Lambda handler to attach logger to AWS request.

        :Example:

        >>> logger = lambo.getLogger(__name__)
        >>>
        >>> @logger.attach
        ... def handler(event, context):
        ...     logger.info('Hello, world!')
        ...     return {'ok': True}
        ...
        >>> handler({'fizz': 'buzz'})
        >>> # => INFO RequestId: {awsRequestId} EVENT {"fizz": "buzz"}
        >>> # => INFO RequestId: {awsRequestId} Hello, world!
        >>> # => INFO RequestId: {awsRequestId} RETURN {"ok": True}
        """
self
handler
Example
>>> logger = lambo.getLogger(__name__)
>>>
>>> @logger.attach
def handler(event, context):
logger.info('Hello, world!')
return {'ok': True}

>>> handler({'fizz': 'buzz'})
>>> # => INFO RequestId: {awsRequestId} EVENT {"fizz": "buzz"}
>>> # => INFO RequestId: {awsRequestId} Hello, world.
>>> # => INFO RequestId: {awsRequestId} RETURN {"ok": True}
>>> logger = lambo . getLogger ( __name__ ) >>> >>> @logger . attach def handler ( event context ) : logger . info ( ' Hello world! ' ) return { ' ok ' : True } >>> handler ( { ' fizz ' : ' buzz ' } ) >>> # = > INFO RequestId : { awsRequestId } EVENT { " fizz " : " buzz " } >>> # = > INFO RequestId : { awsRequestId } Hello world . >>> # = > INFO RequestId : { awsRequestId } RETURN { " ok " : True }