Use "psycopg3" and "psycopg3.pool" as loggers which can be addressed.
Also cleanup of random inconsistencies around logging.
from .utils.compat import asynccontextmanager
from .server_cursor import ServerCursor, AsyncServerCursor
-logger = logging.getLogger(__name__)
-package_logger = logging.getLogger("psycopg3")
+logger = logging.getLogger("psycopg3")
connect: Callable[[str], PQGenConn["PGconn"]]
execute: Callable[["PGconn"], PQGen[List["PGresult"]]]
try:
cb(diag)
except Exception as ex:
- package_logger.exception(
+ logger.exception(
"error processing notice callback '%s': %s", cb, ex
)
from .sched import AsyncScheduler
from .errors import PoolClosed, PoolTimeout, TooManyRequests
-logger = logging.getLogger(__name__)
+logger = logging.getLogger("psycopg3.pool")
class AsyncConnectionPool(BasePool[AsyncConnection]):
# Copyright (C) 2021 The Psycopg Team
-import logging
from random import random
from typing import Any, Callable, Deque, Dict, Generic, Optional
from typing import TYPE_CHECKING
from typing import Counter as TCounter
-logger = logging.getLogger(__name__)
-
-
class BasePool(Generic[ConnectionType]):
# Used to generate pool names
from .sched import Scheduler
from .errors import PoolClosed, PoolTimeout, TooManyRequests
-logger = logging.getLogger(__name__)
+logger = logging.getLogger("psycopg3.pool")
class ConnectionPool(BasePool[Connection]):
self._event.clear()
if task:
- # logger.info("task %s action %s", task, task.action)
if not task.action:
break
try:
if TYPE_CHECKING:
from .connection import Connection, AsyncConnection # noqa: F401
-_log = logging.getLogger(__name__)
+logger = logging.getLogger(__name__)
class Rollback(Exception):
def _rollback_gen(self, exc_val: Optional[BaseException]) -> PQGen[bool]:
if isinstance(exc_val, Rollback):
- _log.debug(
+ logger.debug(
f"{self._conn}: Explicit rollback from: ", exc_info=True
)