diff --git a/lib/Hush/List.pm b/lib/Hush/List.pm index a06f67a..236e5ab 100644 --- a/lib/Hush/List.pm +++ b/lib/Hush/List.pm @@ -4,7 +4,6 @@ use warnings; use Hush::RPC; use Try::Tiny; use File::Spec::Functions; -use Carp qw/longmess/; use Hush::Util qw/barf/; use File::Slurp; diff --git a/lib/Hush/Logger.pm b/lib/Hush/Logger.pm new file mode 100644 index 0000000..67fc3ef --- /dev/null +++ b/lib/Hush/Logger.pm @@ -0,0 +1,21 @@ +package Hush::Logger; +use strict; +use warnings; +use Try::Tiny; +use File::Spec::Functions; + +use Exporter 'import'; +our @EXPORT_OK = qw/debug/; +my $HUSH_CONFIG_DIR = $ENV{HUSH_CONFIG_DIR} || catdir($ENV{HOME},'.hush'); +my $HUSHLIST_CONFIG_DIR = $ENV{HUSH_CONFIG_DIR} || catdir($HUSH_CONFIG_DIR, 'list'); + +sub debug { + my ($msg) = @_; + my $time = localtime(); + my $debug = catfile($HUSHLIST_CONFIG_DIR, 'debug.log'); + open(my $log, '>>', $debug) or barf("Could not open $debug for writing!!!"); + print $log "[$time] [$$] $msg"; + close $log; +} + +1;