Skip to content

Commit 44d3b7b

Browse files
author
James William Pye
committed
Adjust the default client_min_messages to WARNING.
1 parent a6a5a51 commit 44d3b7b

4 files changed

Lines changed: 13 additions & 16 deletions

File tree

postgresql/documentation/changes.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Changes
1010
They are still accessible by python3 -m postgresql.bin.pg_*
1111
* Fix handling of unix domain sockets by pg.open and driver.connect.
1212
[Reported by twitter.com/rintavarustus]
13+
* Set the default client_min_messages level to WARNING.
14+
NOTICEs are often not desired by programmers, and py-postgresql's
15+
high verbosity further irritates that case.
1316

1417
0.9.3 released on 2010-01-01
1518
----------------------------

postgresql/documentation/driver.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1565,6 +1565,7 @@ Or if use of a dictionary is desired::
15651565
When a dictionary is given to construct the row, absent values are filled with
15661566
`None`.
15671567

1568+
.. _db_messages:
15681569

15691570
Database Messages
15701571
=================
@@ -1591,7 +1592,7 @@ propagated any further. However, if a `False` value is returned, the next
15911592
element is checked until the list is exhausted and the message is given to
15921593
`postgresql.sys.msghook`. The normal list of elements is as follows::
15931594

1594-
Output → Statement → Connection → Connector → Driver [→ postgresql.sys]
1595+
Output → Statement → Connection → Connector → Driver → postgresql.sys
15951596

15961597
Where ``Output`` can be a `postgresql.api.Cursor` object produced by
15971598
``declare(...)`` or an implicit output management object used *internally* by

postgresql/documentation/gotchas.txt

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,12 @@ far too verbose. However, considering that py-postgresql is a programmer's
7979
library, the default of high verbosity is taken with the express purpose of
8080
allowing the programmer to "adjust the volume" until appropriate.
8181

82-
There are a number of ways to reduce the noise emitted by a script. In some
83-
cases, the alteration of the ``client_min_messages`` setting is the most
84-
appropriate solution::
85-
86-
>>> db.execute("SET client_min_messages TO WARNING;")
87-
88-
However, py-postgresql provides some additional configuration tools and message
89-
hooks in order to taylor the detail into something more appropriate for a given
90-
application.
91-
92-
See the PostgreSQL documentation for more information on the
93-
``client_min_messages`` setting, and see the Database Messages section in
94-
`postgresql.documentation.driver` for more information on filtering and the
95-
`postgresql.sys.msghook`.
82+
By default, py-postgresql adjusts the ``client_min_messages`` to only emit
83+
messages at the WARNING level or higher--ERRORs, FATALs, and PANICs.
84+
This reduces the number of messages generated by most connections dramatically.
9685

86+
If further customization is needed, the :ref:`db_messages` section has
87+
information on overriding the default action taken with database messages.
9788

9889
Strange TypeError using load_rows() or load_chunks()
9990
----------------------------------------------------

postgresql/driver/pq3.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2309,7 +2309,9 @@ def __init__(self,
23092309
).raise_message()
23102310

23112311
# Startup message parameters.
2312-
tnkw = {}
2312+
tnkw = {
2313+
'client_min_messages' : 'WARNING',
2314+
}
23132315
if self.settings:
23142316
s = dict(self.settings)
23152317
if 'search_path' in self.settings:

0 commit comments

Comments
 (0)