Ok, I'm looking to replace my pathetic home-grown logging package with Log4perl. But I can't find a layout formatter that does what I want - indenting and putting a prefix string before every line in a multi-line string.
For example, with what I have now, I can do the following:
printlog("one\ntwo\n");
indentlog(+1);
printlog("three\nfour\n");
indentlog(-1);
pringlog("five\nsix\n");
The output would look like this:
05/31/06 17:57:37 | one
05/31/06 17:57:37 | two
05/31/06 17:57:37 | three
05/31/06 17:57:37 | four
05/31/06 17:57:37 | five
05/31/06 17:57:37 | six
Obviously, the PatternLayout class can take care of the prefix, but it doesn't handle embedded newlines. And there's an example of doing indentation in the FAQ, but that's with a custom Appender, and I want that functionality in the Layout class so I can use it with both the File appender and the Screen appender.
Surely I'm not the only one that wants something like this. Worst case, I can modify my printlog subroutine to use Log4perl, but I'm hoping for something better than that.
Any suggestions? Thanks.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.