lagury/service/loggers.py
def logging_timeit(logger, format_str, result_funcs=None):
    """
    Timeit logging decorator with argument-based format string

    :param logger: info-level logger
    :param format_str: format string for logger, use execution time as "_time" format argument
    :param result_funcs: dict of "format argument name / function of result" pairs
    """
    result_funcs = result_funcs or {}

    def decorator(func):
        def wrapper(*args, **kwargs):
            started_time = time.time()

            result = func(*args, **kwargs)
            result_args = {name: res_func(result) for name, res_func in result_funcs.items()}

            execution_time = time.time() - started_time

            kwargs.update(result_args)
            logger.info(format_str.format(*args, _time=execution_time, **kwargs))

            return result
        return wrapper
    return decorator

    Timeit logging decorator with argument-based format string

    :param logger: info-level logger
    :param format_str: format string for logger, use execution time as "_time" format argument
    :param result_funcs: dict of "format argument name / function of result" pairs
    
Timeit logging decorator with argument-based format string
Timeit logging decorator with argument - based format string
def logging_timeit(logger, format_str, result_funcs=None):
    result_funcs = result_funcs or {}
    def decorator(func):
        def wrapper(*args, **kwargs):
            started_time = time.time()
            result = func(*args, **kwargs)
            result_args = {name: res_func(result) for name, res_func in result_funcs.items()}
            execution_time = time.time() - started_time
            kwargs.update(result_args)
            logger.info(format_str.format(*args, _time=execution_time, **kwargs))
            return result
        return wrapper
    return decorator
def logging_timeit ( logger , format_str , result_funcs = None ) : result_funcs = result_funcs or { } def decorator ( func ) : def wrapper ( * args , ** kwargs ) : started_time = time . time ( ) result = func ( * args , ** kwargs ) result_args = { name : res_func ( result ) for name , res_func in result_funcs . items ( ) } execution_time = time . time ( ) - started_time kwargs . update ( result_args ) logger . info ( format_str . format ( * args , _time = execution_time , ** kwargs ) ) return result return wrapper return decorator
Timeit logging decorator with argument-based format string
Timeit logging decorator with argument - based format string
"""
    Timeit logging decorator with argument-based format string

    :param logger: info-level logger
    :param format_str: format string for logger, use execution time as "_time" format argument
    :param result_funcs: dict of "format argument name / function of result" pairs
    """
logger
None
format_str
format string for logger, use execution time as "_time" format argument
format string for logger use execution time as " _time " format argument
result_funcs
dict of "format argument name / function of result" pairs
dict of " format argument name / function of result " pairs