Add help, debug log, fix pid file creation

+ Add help in group chat
+ Add debug log ability
* A bit of cleanup
* Check against start uid rather than effective uid when creating pid-file
This commit is contained in:
eleksir
2020-09-06 20:44:54 +03:00
parent f7ecdb870f
commit 20bbfab333
4 changed files with 59 additions and 14 deletions

View File

@@ -11,12 +11,12 @@ use JSON::XS qw(decode_json encode_json);
use Digest::MD5 qw(md5_base64);
use DB_File;
use conf;
use conf qw(loadConf);
use vars qw/$VERSION/;
use Exporter qw(import);
our @EXPORT = qw(weather);
our @EXPORT = qw(weather logger);
$VERSION = "1.0";
@@ -188,6 +188,19 @@ sub __urlencode($) {
return $str;
}
sub logger {
my $msg = shift;
if ($c->{debug_log}) {
my $mode = '>';
$mode = '>>' if (-f $c->{debug_log});
if (open (LOG, $mode, $c->{debug_log})) {
print LOG $msg . "\n";
close LOG;
}
}
}
1;