From: Darold Date: Tue, 3 Jul 2012 21:20:21 +0000 (+0200) Subject: Add possibility to get log from stdin (issue #13) - Tonis Kevvai X-Git-Tag: v3.2~207 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc8ec379f46e1bfb3eeb3788fbb632c477066d65;p=pgbadger Add possibility to get log from stdin (issue #13) - Tonis Kevvai --- diff --git a/README b/README index 5dffe27..0f2c380 100644 --- a/README +++ b/README @@ -8,8 +8,9 @@ SYNOPSIS Arguments: - logfile can be a single log file, a list of files, or a shell command - returning a list of file. + logfile can be a single log file, a list of files, or a shell command + returning a list of file. If you want to pass log content from stdin + use - as filename. Options: @@ -17,7 +18,7 @@ SYNOPSIS be a plain text log or a gzip compressed file with the .gz extension. Note that this option is DEPRECATED: set logfile as a command line argument - instead. + instead. To use stdin set it to character -. -f | --format logtype : possible values: syslog,stderr,csv. Default: stderr -o | --outfile filename: define the filename for the output. Default depends on the output format: out.html or out.txt. To dump @@ -62,6 +63,7 @@ SYNOPSIS pgbadger -p -g /var/log/postgresql/postgresql-2012-05-* pgbadger -p -g --exclude-query="^(COPY|COMMIT)" /var/log/postgresql.log pgbadger -p -g -b "2012-06-25 10:56:11" -e "2012-06-25 10:59:11" /var/log/postgresql.log + cat /var/log/postgres.log | pgbadger -g -p - Reporting errors every week by cron job: diff --git a/doc/pgBadger.pod b/doc/pgBadger.pod index cc7eebd..3cc9c33 100644 --- a/doc/pgBadger.pod +++ b/doc/pgBadger.pod @@ -10,8 +10,10 @@ pgbadger [options] logfile [...] Arguments: - logfile can be a single log file, a list of files, or a shell command - returning a list of file. + logfile can be a single log file, a list of files, or a shell command + returning a list of file. If you want to pass log content from stdin + use - as filename. + Options: @@ -19,7 +21,7 @@ Options: be a plain text log or a gzip compressed file with the .gz extension. Note that this option is DEPRECATED: set logfile as a command line argument - instead. + instead. To use stdin set it to character -. -f | --format logtype : possible values: syslog,stderr,csv. Default: stderr -o | --outfile filename: define the filename for the output. Default depends on the output format: out.html or out.txt. To dump @@ -64,6 +66,7 @@ Examples: pgbadger -p -g /var/log/postgresql/postgresql-2012-05-* pgbadger -p -g --exclude-query="^(COPY|COMMIT)" /var/log/postgresql.log pgbadger -p -g -b "2012-06-25 10:56:11" -e "2012-06-25 10:59:11" /var/log/postgresql.log + cat /var/log/postgres.log | pgbadger -g -p - Reporting errors every week by cron job: diff --git a/pgbadger b/pgbadger index 707c839..c07f745 100755 --- a/pgbadger +++ b/pgbadger @@ -140,13 +140,17 @@ if ($ver) { # of log file to parse. if (!$logfile && ($#ARGV >= 0)) { foreach my $file (@ARGV) { - die "FATAL: logfile $file must exist!\n" if (!-f $file); - next if (-z $file); + if ($file ne '-') { + die "FATAL: logfile $file must exist!\n" if (!-f $file); + next if (-z $file); + } push(@log_files, $file); } } elsif ($logfile) { - die "FATAL: logfile $logfile must exist!\n" if (!-f $logfile); - die "FATAL: logfile $logfile is empty!\n" if (-z $logfile); + if (!$logfile ne '-') { + die "FATAL: logfile $logfile must exist!\n" if (!-f $logfile); + die "FATAL: logfile $logfile is empty!\n" if (-z $logfile); + } push(@log_files, $logfile); } @@ -508,7 +512,8 @@ Usage: pgbadger [options] logfile [...] Arguments: logfile can be a single log file, a list of files or a shell command - returning a list of file. + returning a list of file. If you want to pass log content from stdin + use - as filename. Options: @@ -516,7 +521,7 @@ Options: be a plain text log or a gzip compressed file with the .gz extension. Note that this option is DEPRECATED, set logfile as a command line argument - instead. + instead. To use stdin set it to character -. -f | --format logtype : possible values: syslog,stderr,csv. Default: stderr -o | --outfile filename: define the filename for the output. Default depends of the output format: out.html or out.txt. To dump @@ -561,6 +566,7 @@ Examples: /var/log/postgres.log pgbadger -p -g /var/log/postgresql/postgresql-2012-05-* pgbadger -p -g --exclude-query="^(COPY|COMMIT)" /var/log/postgresql.log + cat /var/log/postgres.log | pgbadger -g -p - Reporting errors every week by cron job: