def _create_mapping(logger:Logger) -> LoggingMapper:
    """
    Create the logging mapping from CookieJar abstract methods to the
    Cookie Jar runtime logging function

    @param   logger  Where to log query times to
    @return  Logging mapping
    """
    mapping = LoggingMapper(logger)
    mapping.map_logging_to_abstract_methods(CookieJar, _CookieJarRuntimeLogging)
    return mapping
Beispiel #2
0
def inject_logging(db: SofterCouchDB, logger: Logger):
    """
    Inject CouchDB response time logging into a SofterCouchDB instance,
    targeting all callable, "public" attributes. Note that we can only
    inject into instantiated SofterCouchDBs because they are monkey-
    patched themselves; as such, we can't use the mass mapping
    convenience functions of the injector.

    @param   db      The SofterCouchDB instance to inject into
    @param   logger  The logger to write to
    """
    mapping = LoggingMapper(logger)
    mapping.map_logging_to_public_methods(db, _CouchDBResponseTimeLogging)
    mapping.inject_logging(db)