pglogger

functions/DEBUG.pg_sql

Functions

DEBUG
Write log message if logging is set to DEBUG or more severe. To get output on standard out, client_min_messages in postgresql.conf needs to be set to debug1 or less severe. With that you can get also debugging messages in the code of PostgreSQL itself.
Syntax:
DEBUG (I_MESSAGE)
Parameters:
ParameterIn/OutData TypeDescription
I_MESSAGEINTEXTValue for LOG.MESSAGE.
Return values:
  • VOID
Copyright:
Thiemo Kellner, 2018 -
Webpage:
https://www.sourceforge.net/projects/pglogger
Version Info:
$Id: DEBUG.pg_sql 7 2018-06-12 04:15:42Z thiemo $
Additional Info:
License LGPLv3
TODO:
  • Once PostgreSQL supports packages, integrate this function into one. For the time being, it should get installed within a schema on its own and no execution grants should be given on it.
  • Once HyperSQL supports a license tag, convert the corresponding info tag into one.

Source

001: \echo Start functions/DEBUG.pg_sql
002: 
003: /** Write log message if logging is set to DEBUG or more severe.
004:  *  To get output on standard out, client_min_messages in postgresql.conf
005:  *  needs to be set to debug1 or less severe. With that you can get also
006:  *  debugging messages in the code of PostgreSQL itself.
007:  *
008:  *  @function DEBUG
009:  *  @return void
010:  *  @param in text I_MESSAGE Value for LOG.MESSAGE.
011:  *  @version $Id: DEBUG.pg_sql 7 2018-06-12 04:15:42Z thiemo $
012:  *  @todo Once PostgreSQL supports packages, integrate this function into one.
013:  *        For the time being, it should get installed within a schema on its
014:  *        own and no execution grants should be given on it.
015:  *  @todo Once HyperSQL supports a license tag, convert the corresponding
016:  *        info tag into one.
017:  *  @copyright Thiemo Kellner, 2018 -
018:  *  @info License LGPLv3
019:  *  @webpage https://www.sourceforge.net/projects/pglogger
020:  */
021: create or replace function DEBUG(
022:     I_MESSAGE text
023: )
024:   returns void
025:   language plpgsql
026:   security definer
027:   stable
028:   -- Include the hosting schema into search_path so that dblink
029:   -- can find the pglogger objects. There is no need to access
030:   -- objects in other schematas not covered with public.
031:   set search_path = :SCHEMA_NAME, public
032:   as
033: $body$
034:     begin
035:         if
036:             GET_LOGGING_LEVEL() in (
037:                 'DEBUG'
038:             )
039:         then
040:             perform WRITE_MESSAGE(
041:                         I_MESSAGE => I_MESSAGE,
042:                         I_LEVEL => 'DEBUG'
043:                     );
044:         end if;
045:     end;
046: $body$;
047: 
048: comment on function DEBUG(I_MESSAGE text) is 'Write log message if logging is set to DEBUG or more severe.
049: To get output on standard out, client_min_messages in postgresql.conf needs to be set to debug1 or less severe. With that you can get also debugging messages in the code of PostgreSQL itself.
050: $Header: svn+ssh://thiemo@svn.code.sf.net/p/pglogger/code/functions/DEBUG.pg_sql 7 2018-06-12 04:15:42Z thiemo $';
051: 
052: commit; -- unlike Oracle not all ddl commit implicitly
053: 
054: \echo End functions/DEBUG.pg_sql


pglogger
Generated by HyperSQL v3.9.8 at Wed Jul 4 07:48:46 2018