Browse Source

commandlog-log: add --debug flag

Prints query and bound values to STDERR.
master
Brennen Bearnes 1 year ago
parent
commit
d21dea7761
3 changed files with 14 additions and 1 deletions
  1. +1
    -0
      Build.PL
  2. +12
    -0
      bin/commandlog-log
  3. +1
    -1
      lib/App/CommandLog.pm

+ 1
- 0
Build.PL View File

@ -7,6 +7,7 @@ my $build = Module::Build->new(
license => 'gpl',
requires => {
'Data::Dumper' => 0,
'File::Spec' => 0,
'Getopt::Long' => 0,
'POSIX' => 0,


+ 12
- 0
bin/commandlog-log View File

@ -23,6 +23,9 @@ commandlog-log - show commandlog history
# Get entries for the current directory:
commandlog log --path .
# Run some query with debugging output enabled:
commandlog log --debug [...]
=head1 AUTHOR
Brennen Bearnes
@ -34,6 +37,7 @@ use strict;
use 5.10.0;
use Cwd;
use Data::Dumper;
use DBI;
use File::Spec;
use Getopt::Long;
@ -44,11 +48,13 @@ use Sys::Hostname;
use App::CommandLog;
# Handle options, including help generated from the POD above.
my $debug = 0;
my $limit;
my $before_date;
my $after_date;
my $path;
GetOptions(
'debug' => \$debug,
'number=s' => \$limit,
'before=s' => \$before_date,
'after=s' => \$after_date,
@ -102,6 +108,12 @@ my ($query, @bind) = $sql->select(
{-desc => 'datetime'}
);
if ($debug) {
say STDERR $query . $limit_clause;
say STDERR Dumper(%where);
say STDERR Dumper(@bind);
}
my $sth = $dbh->prepare($query . $limit_clause);
$sth->execute(@bind);


+ 1
- 1
lib/App/CommandLog.pm View File

@ -14,7 +14,7 @@ App::CommandLog - Tools for logging command line history
package App::CommandLog;
our ($VERSION) = '0.3.0';
our ($VERSION) = '0.4.0';
use strict;
use warnings;


Loading…
Cancel
Save