]> granicus.if.org Git - pgbadger/commitdiff
truncate statement when maxlength is used
authormadtibo <madtibo_git@tribu-ml.fr>
Wed, 23 Jan 2019 13:34:49 +0000 (14:34 +0100)
committermadtibo <madtibo_git@tribu-ml.fr>
Wed, 23 Jan 2019 13:34:49 +0000 (14:34 +0100)
pgbadger

index dbc0330831b233616bc0aa0e1e194f7404cb6a62..7ebd36c4545b3d6808a00bfa8aa7ad2cf9d3bb8b 100755 (executable)
--- a/pgbadger
+++ b/pgbadger
@@ -13989,6 +13989,13 @@ sub store_queries
 
        }
 
+       # We only process stored object with query here
+       if ($cur_info{$t_pid}{statement}) {
+               # Truncate the statement if requested by the user
+               $cur_info{$t_pid}{statement} = substr($cur_info{$t_pid}{statement}, 0, $maxlength) . '[...]'
+                       if (($maxlength > 0) && (length($cur_info{$t_pid}{statement}) > $maxlength));
+       }
+
        my $cur_day_str = "$cur_info{$t_pid}{year}$cur_info{$t_pid}{month}$cur_info{$t_pid}{day}";
        my $cur_hour_str = "$cur_info{$t_pid}{hour}";