Skip Menu |
 

This queue is for tickets about the Net-Server CPAN distribution.

Report information
The Basics
Id: 32226
Status: new
Priority: 0/
Queue: Net-Server

People
Owner: Nobody in particular
Requestors: MARKOV [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in:
  • 0.96
  • 0.97
Fixed in: (no value)



Subject: Use default_values to initialize
Download (untitled) / with headers
text/plain 1.5k
I use Net::Server as base for a new SOAP server implementation (XML::Compile::SOAP::Daemon). My XML modules use the Log::Report infrastructure for translations and logging. I try to merge this with Net::Server's way of logging. Inside Net::Server you use a lot of defaults, for instance log_level=2 and syslog_indent='net_server'. When overruling some logging specific things in my Net::Server based class, I now need to retype those defaults. Of course with the danger that I miss changes in the future. It would be much nicer if Net::Server itself uses its default_values() infrastructure. So, instead of this: ### make sure it has been configured properly sub post_configure { ... ### set the log level if( !defined $prop->{log_level} || $prop->{log_level} !~ /^\d+$/ ){ $prop->{log_level} = 2; } $prop->{log_level} = 4 if $prop->{log_level} > 4; ### log to STDERR if( ! defined($prop->{log_file}) ){ $prop->{log_file} = ''; ### log to syslog }elsif( $prop->{log_file} eq 'Sys::Syslog' ){ ... } ### any values to set if no configuration could be found sub default_values { {} } It could be written as ### make sure it has been configured properly sub post_configure { ... ### set the log level $prop->{log_level} =~ /^\d+$/ && $prop->{log_level} <= 4 or die; ### log to syslog if( $prop->{log_file} eq 'Sys::Syslog' ){ ... } ### any values to set if no configuration could be found sub default_values { +{log_level => 2, log_file => ''} } This would improve the clarity of the code a lot, and simplify complex extensions. I hope you see the benefits.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.