Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Whilst the above suggestions all solve the problem at hand, if the amount of stuff you're logging out gets significant it's normally a good idea to switch to using one of the many Perl modules that handle logging in a more complete manner.

Amongst the useful capabilities that a decent logging package (I personally use Log4Perl, but many others exist) are:

  • Actual details of configuration can be stored either in the program, or a seperate log configuration file. This allows them to be easily changed.

  • Pluggable log dispatch system. This allows you to easily set up a situation where, for example, all messages are logged to a file, a database, and printed to screen, but those which are exceptionally important are actually emailled to someone to deal with.
  • Capable of having multiple log-files, so you could have your database errors put into one log and any system failures into another if the two types of error were to be handled by different people.
  • Ability to change logging levels on-the-fly. By using a configuration file to control the level of detail of logging it's trivial to switch from 'Standard' levels of logging to 'Debug' when things start going wrong, all without needing to edit code and (in the case of Log4perl at least) potentially without needing to restart the service. The logging-levels can even be changed on a per-logfile basis so you could have the extra detail only when needed.
  • Keeps code simple and tidy. With the handling of the errorfile etc. kept in it's own set of external modules your own code is kept nice and simple, free of the kind of errorhandling cruft.
  • A robust solution, the more used logging modules are used by a considerable number of people so are generally quite well tested and very unlikely to cause problems unless you're doing some very bizarre things with them.
  • Simple interface. Most logging systems try and keep things simple, and provide nice drop-in replacements for die, warn etc.

Sorry if it seems like I am randomly soap-boxing, it's just that I noticed that the usability and power of the logging in the more complex systems that I write has been notably improved since I started to use this module.

In reply to Recommendation for Logging modules by Molt
in thread How do I print errors by SQLMan

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • 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.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2023-12-04 08:57 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (23 votes). Check out past polls.