Skip to content

Commit

Permalink
You can now change the log handler at any time
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerbinns committed May 15, 2023
1 parent d4e18c3 commit 10b86bf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
10 changes: 1 addition & 9 deletions doc/tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ APSW/SQLite was operating on.
SQLite has a `warning/error logging facility
<http://www.sqlite.org/errlog.html>`__. You can call
:meth:`apsw.ext.log_sqlite` which installs a handler that forwards
SQLite messages to the `logging module
<https://docs.python.org/3/library/logging.html>`__.
SQLite messages to the :mod:`logging module <logging>`.`

To do it yourself::

Expand All @@ -168,13 +167,6 @@ To do it yourself::

apsw.config(apsw.SQLITE_CONFIG_LOG, handler)

.. note::

The handler **must** be set before any other calls to SQLite.
Once SQLite is initialised you cannot change the logger - a
:exc:`MisuseError` will happen (this restriction is in SQLite not
APSW).

This is an example of what gets printed when I use ``/dev/null`` as
the database name in the :class:`Connection` and then tried to create
a table.
Expand Down
3 changes: 1 addition & 2 deletions example-code.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@

### logging: Logging
# It is a good idea to get SQLite's logs as you will get more
# information about errors. This has to be done first (a SQLite
# limitation, not APSW). :meth:`apsw.ext.log_sqlite` forwards
# information about errors. :meth:`apsw.ext.log_sqlite` forwards
# SQLite's log messages to the :mod:`logging` module.

apsw.ext.log_sqlite()
Expand Down

0 comments on commit 10b86bf

Please sign in to comment.