You really haven't given all your requirements here, so I apologize if this is a useless suggestion.
I've had success using Data::Dumper or YAML (or its XS replacement YAML::Syck) to dump structures to a file, which is then referenced in the log file. I use a sub that looks something like:
# assumes-> use File::Temp ':POSIX'; for tempnam()
# assumes-> use YAML 'Dump'; (or) use YAML::Syck 'Dump'; for Dump()
sub dump {
my $message = shift;
my $structures = scalar @_; # yes, 'scalar' is redudant, but reada
+ble
# create file in curdir with prefix 'dump.'
my ($dump_h, $dump_n) = tempnam('.','dump.');
print $dump_h, Dump($_) for @_;
close $dump_h;
$message.=sprintf '(%d dumped to "%s")', $structures, $dump_n;
}
And would be called something like:
$logger->fatal( dump('Unable to foo, dumping object $foo_doer.', $foo_
+doer) );
The log line would look something like:
20070314 15:09 FATAL: Unable to foo, dumping object $foo_doer.(1 dumpe
+d to "dump.foobar1")
And the file "dump.foobar1" would contain the $foo_doer serialization.
You can equally use Data::Dumper or any other serialization module you prefer using this model.
<–radiant.matrix–>
Ramblings and references
The Code that can be seen is not the true Code
I haven't found a problem yet that can't be solved by a well-placed trebuchet
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.