use fields qw(socket target);
use YAML qw/LoadFile/;
-my $debug = 0;
+my $debug = $ENV{DEBUG} || 0;
+$|=1; # flush STDOUT
my $config = {
yaml_dir => './yaml/',
my $log_fh;
sub log {
+ my $level = $1 if $_[0] =~ m/^(#+)/;
+ return if defined($level) && length($level) > $debug;
+
+ warn join("\n", @_);
+
return unless $config->{log_file};
if ( ! $log_fh ) {
}
BEGIN {
- $SIG{'__WARN__'} = sub { warn @_; main::log(@_); }
+ $SIG{'__WARN__'} = sub { main::log(@_); }
}
# read from client
asn_read($clientsocket, my $reqpdu);
if ( ! $reqpdu ) {
- warn "client closed connection\n";
+ warn "# client closed connection\n";
return 0;
}
$reqpdu = log_request($reqpdu);
if ( defined $response->{protocolOp}->{searchResEntry} ) {
my $uid = $response->{protocolOp}->{searchResEntry}->{objectName};
- print "rewrite objectName $uid\n";
+ warn "# rewrite objectName $uid\n";
my @attrs;