|
From: Lee C. <lec...@ya...> - 2004-08-24 13:25:14
|
Hello Mike,
> I typically use the term "derived class".
As yes. It was the end of a long day. Thank you.
> Can you provide more details on what the derived
> class will be provide
> differently than the base class? If you're
> overriding filename(), you
> probably also have to override the constructor,
> which doesn't leave much
> base class functionality left.
Sure. Basically I have one derived class that creates
a sub directory to put the logfile in if a MDC key =>
value have been set. There has been a request by our
ops folks to make the logs use a daily date format. My
plan was to leave the sub directory class alone and
just derive another class from it where I used the
'Date::Format' modules 'time2str' to allow the format
to be set in the configuration then override the
'filename' method to call the 'time2str' function for
the name so this was continually updated with the
correct date instead of ever setting/updating the
'filename' attribute. This way the filename value is
always the log pattern not the actual date but the
filename when used by 'file_open' is the real date. It
does mean I have to make a constructor but this inits
one attribute for my class and calls the constructor
for the super class. I thought about doing it with the
by overriding the log method and just continuely
updating the logfile with the 'file_switch' but it
seemed just as easy to do it this way.
I have attached the second class, it isn't very long.
In this one, I am accessing the internal 'filename'
attribute but I meant to update this to use my own
value.
sub new
{
my($class, %options) = @_;
my $self = $class->SUPER::new(%options);
$self->{'ofilename'} = $options{'filename'};
bless($self, $class);
return($self);
}
sub filename
{
my $self = shift;
## the 'filename' here could be a differ attribute
for only this class
return time2str($self->{filename}, time());
}
Thanks for your time,
Lee
_______________________________
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush
|