Source code for postgresql.sys
##
# .sys
##
"""
py-postgresql system functions and data.
Data
----
``libpath``
The local file system paths that contain query libraries.
Overridable Functions
---------------------
excformat
Information that makes up an exception's displayed "body".
Effectively, the implementation of `postgresql.exception.Error.__str__`
msghook
Display a message.
"""
import sys
import os
import traceback
from .python.element import format_element
from .python.string import indent
libpath = []
[docs]def default_msghook(msg, format_message = format_element):
"""
Built-in message hook. DON'T TOUCH!
"""
if sys.stderr and not sys.stderr.closed:
try:
sys.stderr.write(format_message(msg) + os.linesep)
except Exception:
try:
sys.excepthook(*sys.exc_info())
except Exception:
# gasp.
pass
[docs]def msghook(*args, **kw):
"""
Message hook pointing to default_msghook.
Override if you like. All untrapped messages raised by
driver connections come here to be printed to stderr.
"""
return default_msghook(*args, **kw)
[docs]def reset_msghook(with_func = msghook):
'restore the original msghook function'
global msghook
msghook = with_func