pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Patch to add a new loglevel(OFF) to turn off logging
2+ messages / 2 participants
[nested] [flat]

* Patch to add a new loglevel(OFF) to turn off logging
@ 2013-02-18 10:50  Chen Huajun <chenhj@cn.fujitsu.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Chen Huajun @ 2013-02-18 10:50 UTC (permalink / raw)
  To: pgsql-jdbc

Hi,

As discussed before, adding a new loglevel explicitly
to turn off logging may be useful sometimes.

For example:
Driver.setLogLevel() ;//open a JVM level's logging
con = DriverManager.getConnection(connectionString)//want to turn off logging in this Connection

or
Driver.setLogLevel() ;//open logging
//do something
Driver.setLogLevel() ;//want to turn off logging
//do other things


And I have wrote a simple patch for that,
Hopefully this useful.

*)if be accepted,document about loglevel should be updated

-- 
Best Regards,
Chen Huajun

-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

Attachments:

pgjdbc_new_loglevel_OFF.patch (text/plain, 1.9K) download diff --git a/org/postgresql/Driver.java.in b/org/postgresql/Driver.java.in index 5f20a4e..ad5e938 100644 --- a/org/postgresql/Driver.java.in +++ b/org/postgresql/Driver.java.in @@ -50,7 +50,8 @@ public static final int DEBUG = 2; public static final int INFO = 1; - + public static final int OFF = 0; + private static final Logger logger = new Logger(); private static boolean logLevelSet = false; private static Timer cancelTimer=null; @@ -189,8 +190,8 @@ * otherwise the jvm character encoding is used as the default. * This value is only used when connecting to a 7.2 or older server. * loglevel - (optional) Enable logging of messages from the driver. - * The value is an integer from 1 to 2 where: - * INFO = 1, DEBUG = 2 + * The value is an integer from 0 to 2 where: + * OFF = 0, INFO = 1, DEBUG = 2 * The output is sent to DriverManager.getPrintWriter() if set, * otherwise it is sent to System.out. * compatible - (optional) This is used to toggle @@ -446,7 +447,7 @@ { "sslfactoryarg", Boolean.FALSE, "Argument forwarded to constructor of SSLSocketFactory class." }, { "loglevel", Boolean.FALSE, - "Control the driver's log verbosity: 0 is off, 1 is INFO, 2 is DEBUG.", + "Control the driver's log verbosity: 0 is OFF, 1 is INFO, 2 is DEBUG.", new String[] { "0", "1", "2" } }, { "allowEncodingChanges", Boolean.FALSE, "Allow the user to change the client_encoding variable." }, @@ -727,6 +728,7 @@ * used to turn logging on to a certain level, can be called * by specifying fully qualified class ie org.postgresql.Driver.setLogLevel() * @param logLevel sets the level which logging will respond to + * OFF turn off logging * INFO being almost no messages * DEBUG most verbose */=
^ permalink raw reply [nested|flat] 2+ messages in thread

* Re: Patch to add a new loglevel(OFF) to turn off logging
@ 2013-02-20 11:42  Dave Cramer <pg@fastcrypt.com>
  parent: Chen Huajun <chenhj@cn.fujitsu.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Dave Cramer @ 2013-02-20 11:42 UTC (permalink / raw)
  To: Chen Huajun <chenhj@cn.fujitsu.com>; +Cc: pgsql-jdbc

Chen,

Thanks for the patch, it has been applied

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca


On Mon, Feb 18, 2013 at 5:50 AM, Chen Huajun <chenhj@cn.fujitsu.com> wrote:

> Hi,
>
> As discussed before, adding a new loglevel explicitly
> to turn off logging may be useful sometimes.
>
> For example:
> Driver.setLogLevel() ;//open a JVM level's logging
> con = DriverManager.getConnection(connectionString)//want to turn off
> logging in this Connection
>
> or
> Driver.setLogLevel() ;//open logging
> //do something
> Driver.setLogLevel() ;//want to turn off logging
> //do other things
>
>
> And I have wrote a simple patch for that,
> Hopefully this useful.
>
> *)if be accepted,document about loglevel should be updated
>
> --
> Best Regards,
> Chen Huajun
>
>
>
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
>
>

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2013-02-20 11:42 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-02-18 10:50 Patch to add a new loglevel(OFF) to turn off logging Chen Huajun <chenhj@cn.fujitsu.com>
2013-02-20 11:42 ` Dave Cramer <pg@fastcrypt.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox