DBI::ProxyServer:写入日志文件时出现问题
启动代理服务器 (DBI::ProxyServer) 时,
dbiproxy --logfile C:\WINDOWS\temp\dbiproxy.log --debug 1 --localport 2000
一切正常
dbiproxy --configfile dbiproxy.config
,除了日志文件的写入。
我的 dbiproxy 配置文件:
{ 'logfile' => 'C:\WINDOWS\temp\dbiproxy.log',
'localport' => '2000',
'debug' => 1, }
我传递了一个文件名,但是 Net::Daemon: :Log 需要文件句柄。
是代码不正确还是我错过了什么?
# Net/Daemon.pm
sub ReadConfigFile {
my($self, $file, $options, $args) = @_;
# ...
my $copts = do $file;
# ...
# Override current configuration with config file options.
while (my($var, $val) = each %$copts) {
$self->{$var} = $val;
}
}
sub new ($$;$) {
my($class, $attr, $args) = @_;
my($self) = $attr ? \%$attr : {};
bless($self, (ref($class) || $class));
my $options = ($self->{'options'} ||= {});
# ...
# ...
my $file = $options->{'configfile'} || $self->{'configfile'};
if ($file) {
$self->ReadConfigFile($file, $options, $args);
}
while (my($var, $val) = each %$options) {
$self->{$var} = $val;
}
# ...
# ...
$self;
}
# Net/Daemon/Log.pm
sub OpenLog($) {
my $self = shift;
return 1 unless ref($self);
return $self->{'logfile'} if defined($self->{'logfile'});
# ...
# ...
}
sub Log ($$$;@) {
my($self, $level, $format, @args) = @_;
my $logfile = !ref($self) || $self->OpenLog();
# ...
# ...
if ($logfile) {
my $logtime = $self->LogTime();
# <- get this far, but don't pass the "ref($logfile)"
if (ref($logfile)) {
$logfile->print(sprintf("$logtime $level, $tid$format\n", @args));
} else {
printf STDERR ("$logtime $level, $tid$format\n", @args);
}
} elsif (my $eventLog = $self->{'eventLog'}) {
# ...
# ...
}
When starting the proxyserver (DBI::ProxyServer) with
dbiproxy --logfile C:\WINDOWS\temp\dbiproxy.log --debug 1 --localport 2000
or with
dbiproxy --configfile dbiproxy.config
everything works, except the writing of a logfile.
My dbiproxy config file:
{ 'logfile' => 'C:\WINDOWS\temp\dbiproxy.log',
'localport' => '2000',
'debug' => 1, }
I pass a filename, but the Net::Daemon::Log needs a filehandle.
Is the code not OK or have I missed something?
# Net/Daemon.pm
sub ReadConfigFile {
my($self, $file, $options, $args) = @_;
# ...
my $copts = do $file;
# ...
# Override current configuration with config file options.
while (my($var, $val) = each %$copts) {
$self->{$var} = $val;
}
}
sub new ($;$) {
my($class, $attr, $args) = @_;
my($self) = $attr ? \%$attr : {};
bless($self, (ref($class) || $class));
my $options = ($self->{'options'} ||= {});
# ...
# ...
my $file = $options->{'configfile'} || $self->{'configfile'};
if ($file) {
$self->ReadConfigFile($file, $options, $args);
}
while (my($var, $val) = each %$options) {
$self->{$var} = $val;
}
# ...
# ...
$self;
}
# Net/Daemon/Log.pm
sub OpenLog($) {
my $self = shift;
return 1 unless ref($self);
return $self->{'logfile'} if defined($self->{'logfile'});
# ...
# ...
}
sub Log ($$;@) {
my($self, $level, $format, @args) = @_;
my $logfile = !ref($self) || $self->OpenLog();
# ...
# ...
if ($logfile) {
my $logtime = $self->LogTime();
# <- get this far, but don't pass the "ref($logfile)"
if (ref($logfile)) {
$logfile->print(sprintf("$logtime $level, $tid$format\n", @args));
} else {
printf STDERR ("$logtime $level, $tid$format\n", @args);
}
} elsif (my $eventLog = $self->{'eventLog'}) {
# ...
# ...
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
怎么样
将其放入 dbiproxy 配置文件 ?我没有办法测试它,但根据 Net: :Daemon::Log 文档它应该可以工作。
What about putting
into your dbiproxy config file? I don't have a way how to test it, but according to Net::Daemon::Log docs it should work.