added log file
[virtual-ldap] / bin / ldap-rewrite.pl
index 6d2fa2d..a6eff6e 100755 (executable)
@@ -24,9 +24,23 @@ my $config = {
        upstream_ldap => 'ldap.ffzg.hr',
        upstream_ssl => 1,
        overlay_prefix => 'ffzg-',
+       log_file => 'log',
 
 };
 
+my $log_fh;
+
+sub log {
+       open($log_fh, '>', $config->{log_file}) || die "can't open ", $config->{log_file},": $!";
+       $log_fh->autoflush(1);
+       print $log_fh join("\n", @_),"\n";
+}
+
+BEGIN {
+       $SIG{'__WARN__'} = sub { warn @_; main::log(@_); }
+}
+
+
 if ( ! -d $config->{yaml_dir} ) {
        warn "DISABLE ", $config->{yaml_dir}," data overlay";
 }
@@ -153,6 +167,8 @@ sub run_proxy {
 }
 
 
+$ENV{LANG} = 'C'; # so we don't double-encode utf-8 if LANG is utf-8
+
 my $listenersock = IO::Socket::INET->new(
        Listen => 5,
        Proto => 'tcp',