Re: Tom Lane 2016-09-29 <18642.1475159...@sss.pgh.pa.us>
> > Possibly the longer version could be added as an example in the
> > documentation.
> 
> I suspect that simply having a nonempty default in the first place
> is going to do more to raise peoples' awareness than anything we
> could do in the documentation.  But perhaps an example along these
> lines would be useful for showing proper use of %q.

Patch attached. (Still using %t, I don't think %m makes sense for the
default.)

Christoph
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
new file mode 100644
index e826c19..a4d8b74
*** a/doc/src/sgml/config.sgml
--- b/doc/src/sgml/config.sgml
*************** local0.*    /var/log/postgresql
*** 5004,5010 ****
           value will pad on the left. Padding can be useful to aid human
           readability in log files.
           This parameter can only be set in the <filename>postgresql.conf</>
!          file or on the server command line. The default is an empty string.
  
           <informaltable>
            <tgroup cols="3">
--- 5004,5011 ----
           value will pad on the left. Padding can be useful to aid human
           readability in log files.
           This parameter can only be set in the <filename>postgresql.conf</>
!          file or on the server command line. The default is
!          <literal>%t [%p] </> which logs a time stamp and the process ID.
  
           <informaltable>
            <tgroup cols="3">
*************** FROM pg_stat_activity;
*** 5142,5147 ****
--- 5143,5159 ----
           include those escapes if you are logging to <application>syslog</>.
          </para>
         </tip>
+ 
+        <tip>
+         <para>
+          The <literal>%q</> escape is useful when including information that 
is
+          only available in session (backend) context like user or database
+          name. An example would be:
+ <programlisting>
+ log_line_prefix = '%t [%p] %q%u@%d/%a '
+ </programlisting>
+         </para>
+        </tip>
        </listitem>
       </varlistentry>
  
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
new file mode 100644
index cced814..b71fa93
*** a/src/backend/utils/misc/guc.c
--- b/src/backend/utils/misc/guc.c
*************** static struct config_string ConfigureNam
*** 3014,3020 ****
                        gettext_noop("If blank, no prefix is used.")
                },
                &Log_line_prefix,
!               "",
                NULL, NULL, NULL
        },
  
--- 3014,3020 ----
                        gettext_noop("If blank, no prefix is used.")
                },
                &Log_line_prefix,
!               "%t [%p] ",
                NULL, NULL, NULL
        },
  
diff --git a/src/backend/utils/misc/postgresql.conf.sample 
b/src/backend/utils/misc/postgresql.conf.sample
new file mode 100644
index 05b1373..9eaa23e
*** a/src/backend/utils/misc/postgresql.conf.sample
--- b/src/backend/utils/misc/postgresql.conf.sample
***************
*** 430,436 ****
  #log_duration = off
  #log_error_verbosity = default                # terse, default, or verbose 
messages
  #log_hostname = off
! #log_line_prefix = ''                 # special values:
                                        #   %a = application name
                                        #   %u = user name
                                        #   %d = database name
--- 430,436 ----
  #log_duration = off
  #log_error_verbosity = default                # terse, default, or verbose 
messages
  #log_hostname = off
! #log_line_prefix = '%t [%p] '         # special values:
                                        #   %a = application name
                                        #   %u = user name
                                        #   %d = database name
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to