]> granicus.if.org Git - pgbadger/commitdiff
Add -C | --nocomment option to remove comment like /* ... */ from queries. Thanks...
authorDarold Gilles <gilles@darold.net>
Thu, 18 Oct 2012 21:14:24 +0000 (23:14 +0200)
committerDarold Gilles <gilles@darold.net>
Thu, 18 Oct 2012 21:14:24 +0000 (23:14 +0200)
README
doc/pgBadger.pod
pgbadger

diff --git a/README b/README
index fb909c1432762d76e1ab46929a504e594001491f..844069b4c7d80535a9ed074fb65f03f329ccce3b 100644 (file)
--- a/README
+++ b/README
@@ -17,6 +17,8 @@ SYNOPSIS
         -a | --average minutes : number of minutes to build the average graphs of
                                  queries and connections.
         -b | --begin datetime  : start date/time for the data to be parsed in log.
+        -c | --dbclient host   : only report what concern the given client host.
+        -C | --nocomment       : remove comments like /* ... */ from queries.
         -d | --dbname database : only report what concern the given database
         -e | --end datetime    : end date/time for the data to be parsed in log.
         -f | --format logtype  : possible values: syslog,stderr,csv. Default: stderr.
index 7f871ffb76b78efe10493c8d1246153df86c42a8..001a04db08982536ca77a12573b05237aea96133 100644 (file)
@@ -19,6 +19,8 @@ Options:
     -a | --average minutes : number of minutes to build the average graphs of
                              queries and connections.
     -b | --begin datetime  : start date/time for the data to be parsed in log.
+    -c | --dbclient host   : only report what concern the given client host.
+    -C | --nocomment       : remove comments like /* ... */ from queries.
     -d | --dbname database : only report what concern the given database
     -e | --end datetime    : end date/time for the data to be parsed in log.
     -f | --format logtype  : possible values: syslog,stderr,csv. Default: stderr.
index d8d076a8cd6d92e2a4aad67632d1417fa94ad376..2aae67241fa9bdaa493d996f650c879be0e88cc6 100755 (executable)
--- a/pgbadger
+++ b/pgbadger
@@ -95,6 +95,7 @@ my $t_min_hour          = 0;
 my $t_max_hour          = 0;
 my $log_duration        = 0;
 my $enable_log_duration = 0;
+my $remove_comment      = 0;
 my $enable_log_min_duration = 0;
 
 my $NUMPROGRESS = 10000;
@@ -118,6 +119,7 @@ my $result = GetOptions(
        "a|average=i"         => \$avg_minutes,
        "b|begin=s"           => \$from,
        "c|client=s"          => \$dbclient,
+       "C|nocomment!"         => \$remove_comment,
        "d|dbname=s"          => \$dbname,
        "e|end=s"             => \$to,
        "f|format=s"          => \$format,
@@ -835,6 +837,7 @@ Options:
                             queries and connections.
     -b | --begin datetime  : start date/time for the data to be parsed in log.
     -c | --dbclient host   : only report what concern the given client host.
+    -C | --nocomment       : remove comments like /* ... */ from queries.
     -d | --dbname database : only report what concern the given database.
     -e | --end datetime    : end date/time for the data to be parsed in log.
     -f | --format logtype  : possible values: syslog,stderr,csv. Default: stderr.
@@ -3514,6 +3517,11 @@ sub store_queries
 {
        my $t_pid = shift;
 
+       # Remove comments if required
+       if ($remove_comment) {
+               $cur_info{$t_pid}{query} =~ s/\/\*(.*?)\*\///gs;
+       }
+
        # Cleanup and normalize the current query
        $cur_info{$t_pid}{query} =~ s/^[\t\s]+//s;
        $cur_info{$t_pid}{query} =~ s/[\t\s]+$//s;