]> granicus.if.org Git - pgbadger/commitdiff
Add new option -M | --no-multiline to not collect multiline statement to avoid garbag...
authorDarold Gilles <gilles@darold.net>
Fri, 17 Oct 2014 16:23:20 +0000 (18:23 +0200)
committerDarold Gilles <gilles@darold.net>
Fri, 17 Oct 2014 16:23:20 +0000 (18:23 +0200)
README
doc/pgBadger.pod
pgbadger

diff --git a/README b/README
index 3dba42b1480417662394310416df818f178fee20..48cdcb13b4bf56a81c14f864f6c80a19c3d03f00 100644 (file)
--- a/README
+++ b/README
@@ -42,6 +42,8 @@ SYNOPSIS
                                  report per day with a log rotated each week.
         -m | --maxlength size  : maximum length of a query, it will be restricted to
                                  the given size. Default: no truncate
+        -M | --no-multiline    : do not collect multiline statement to avoid garbage
+                                 especially on errors that generate a huge report.
         -n | --nohighlight     : disable SQL code highlighting.
         -N | --appname name    : only report on entries for given application name
         -o | --outfile filename: define the filename for the output. Default depends
index 30d42475c7d6fc096d16316aab522635a1e58cf8..34abf3f276e59bf701428061a31dda370141a40c 100644 (file)
@@ -44,6 +44,8 @@ Options:
                              report per day with a log rotated each week.
     -m | --maxlength size  : maximum length of a query, it will be restricted to
                              the given size. Default: no truncate
+    -M | --no-multiline    : do not collect multiline statement to avoid garbage
+                             especially on errors that generate a huge report.
     -n | --nohighlight     : disable SQL code highlighting.
     -N | --appname name    : only report on entries for given application name
     -o | --outfile filename: define the filename for the output. Default depends
index 937bf529eb9b1f72952f6aff790d7d7d615a7365..592989be564fda89d80786153a76250dc5b1c1ee 100755 (executable)
--- a/pgbadger
+++ b/pgbadger
@@ -227,6 +227,7 @@ my $noclean                 = 0;
 my $retention               = 0;
 my $bar_graph               = 0;
 my $dns_resolv              = 0;
+my $nomultiline             = 0;
 
 my $NUMPROGRESS = 10000;
 my @DIMENSIONS  = (800, 300);
@@ -321,6 +322,7 @@ my $result = GetOptions(
        "J|job_per_file=i"         => \$job_per_file,
        "l|last-parsed=s"          => \$last_parsed,
        "m|maxlength=i"            => \$maxlength,
+       "M|no-multiline!"          => \$nomultiline,
        "N|appname=s"              => \@dbappname,
        "n|nohighlight!"           => \$nohighlight,
        "o|outfile=s"              => \$outfile,
@@ -1573,6 +1575,8 @@ Options:
                              report per day with a log rotated each week.
     -m | --maxlength size  : maximum length of a query, it will be restricted to
                              the given size. Default: no truncate
+    -M | --no-multiline    : do not collect multiline statement to avoid garbage
+                             especially on errors that generate a huge report.
     -n | --nohighlight     : disable SQL code highlighting.
     -N | --appname name    : only report on entries for given application name
     -o | --outfile filename: define the filename for the output. Default depends
@@ -2204,40 +2208,40 @@ sub process_file
                                        } 
 
                                        # Some log line may be written by applications
-                                       next if ($line =~ / LOG:  /);
+                                       next if ($line =~ /\bLOG:  /);
 
                                        if (exists $cur_temp_info{$cur_pid}{query}) {
                                                $cur_temp_info{$cur_pid}{query} .= "\n" . $t_query;
                                        } elsif (exists $cur_lock_info{$cur_pid}{query}) {
                                                $cur_lock_info{$cur_pid}{query} .= "\n" . $t_query;
                                        } elsif (exists $cur_info{$cur_pid}{statement}) {
-                                               $cur_info{$cur_pid}{statement} .= "\n" . $t_query;
+                                               $cur_info{$cur_pid}{statement} .= "\n" . $t_query if (!$nomultiline);
                                        } elsif (exists $cur_info{$cur_pid}{context}) {
                                                $cur_info{$cur_pid}{context} .= "\n" . $t_query;
                                        } elsif (exists $cur_info{$cur_pid}{detail}) {
                                                $cur_info{$cur_pid}{detail} .= "\n" . $t_query;
                                        } elsif (exists $cur_info{$cur_pid}{query}) {
-                                               $cur_info{$cur_pid}{query} .= "\n" . $t_query;
+                                               $cur_info{$cur_pid}{query} .= "\n" . $t_query if (!$nomultiline);
                                        }
 
                                # Collect orphaned lines of multiline queries
                                } elsif ($cur_pid && ($line !~ $orphan_syslog_line)) {
 
                                        # Some log line may be written by applications
-                                       next if ($line =~ / LOG:  /);
+                                       next if ($line =~ /\bLOG:  /);
 
                                        if (exists $cur_temp_info{$cur_pid}{query}) {
                                                $cur_temp_info{$cur_pid}{query} .= "\n" . $line;
                                        } elsif (exists $cur_lock_info{$cur_pid}{query}) {
                                                $cur_lock_info{$cur_pid}{query} .= "\n" . $line;
                                        } elsif (exists $cur_info{$cur_pid}{statement}) {
-                                               $cur_info{$cur_pid}{statement} .= "\n" . $line;
+                                               $cur_info{$cur_pid}{statement} .= "\n" . $line if (!$nomultiline);
                                        } elsif (exists $cur_info{$cur_pid}{context}) {
                                                $cur_info{$cur_pid}{context} .= "\n" . $line;
                                        } elsif (exists $cur_info{$cur_pid}{detail}) {
                                                $cur_info{$cur_pid}{detail} .= "\n" . $line;
                                        } elsif (exists $cur_info{$cur_pid}{query}) {
-                                               $cur_info{$cur_pid}{query} .= "\n" . $line;
+                                               $cur_info{$cur_pid}{query} .= "\n" . $line if (!$nomultiline);
                                        }
 
                                } else {
@@ -2343,20 +2347,20 @@ sub process_file
                                        } 
 
                                        # Some log line may be written by applications
-                                       next if ($line =~ / LOG:  /);
+                                       next if ($line =~ /\bLOG:  /);
 
                                        if (exists $cur_temp_info{$cur_pid}{size}) {
                                                $cur_temp_info{$cur_pid}{query} .= "\n" . $line;
                                        } elsif (exists $cur_lock_info{$cur_pid}{query}) {
                                                $cur_lock_info{$cur_pid}{query} .= "\n" . $line;
                                        } elsif (exists $cur_info{$cur_pid}{statement}) {
-                                               $cur_info{$cur_pid}{statement} .= "\n" . $line;
+                                               $cur_info{$cur_pid}{statement} .= "\n" . $line if (!$nomultiline);
                                        } elsif (exists $cur_info{$cur_pid}{context}) {
                                                $cur_info{$cur_pid}{context} .= "\n" . $line;
                                        } elsif (exists $cur_info{$cur_pid}{detail}) {
                                                $cur_info{$cur_pid}{detail} .= "\n" . $line;
                                        } elsif (exists $cur_info{$cur_pid}{query}) {
-                                               $cur_info{$cur_pid}{query} .= "\n" . $line;
+                                               $cur_info{$cur_pid}{query} .= "\n" . $line if (!$nomultiline);
                                        }
 
                                # Collect orphaned lines of multiline queries