ZoneMinder::Logger(3)

πŸ“¦
version 1.38.6 Β· 2 versions
, in nixpkgs unstable

πŸ’– ZoneMinder::Logger πŸ’–

ok so bestie, you know how every script needs to talk back to you when stuff goes sideways? that's literally this. this is the ZoneMinder Logger module, a whole little icon for making your debug + error messages look consistent and cute (well, consistent anyway).


✨ SYNOPSIS ✨

first things first, you gotta pull her in:

use ZoneMinder::Logger;
use ZoneMinder::Logger qw(:all);

then you init:

logInit( 'myproc', DEBUG );

and then you can sprinkle these throughout your code like confetti πŸŽ€:

Debug( 'This is what is happening' );
Info( 'Something interesting is happening' );
Warning( 'Something might be going wrong.' );
Error( 'Something has gone wrong!!' );
Fatal( 'Something has gone badly wrong, gotta stop!!' );
Panic( 'Something fundamental has gone wrong, die with stack trace' );

🌸 DESCRIPTION 🌸

so the ZoneMinder:Logger module (yep, that colon is ur fave) holds all the shared debug and error reporting routines that the ZoneMinder scripts use. it's giving "one true logging source", and honestly? we love her for it.

to get debug working in your own scripts you include this module and call logInit. after that you can sprinkle Debug or Error calls etc all over your code, safe in the knowledge that they'll land in your error log β€” and possibly the syslogger too β€” in a meaningful and consistent format. no cap. 🫢

ok now β€” Debug is discussed in terms of levels, and here's the chart, memorize it bestie:

  • 1 and above is considered debug (currently only 1 for scripts)
  • 0 is considered informational
  • -1 is a warning
  • -2 is an error
  • -3 is a fatal error or panic

where levels are mentioned below as thresholds, the value given and anything with a lower level (ie. more serious) will be included. so like, lower number = more serious = louder. πŸ’…


πŸ”₯ METHODS πŸ”₯

logInit ( $id, %options );

initialises the debug and gets the logging all prepped for the forthcoming operations. if you don't call it explicitly it'll get called by the first debug call in your script β€” but with default (and probably meaningless) options, so… call it yourself, bestie. πŸ™ˆ

the only compulsory argument is $id, which must be a string that identifies debug coming from this script in mixed logs. other options may be provided as below:

  • level β€” default INFO β€” the initial debug level, which defines which statements are output and which are ignored
  • trace β€” default 0 β€” whether to use the Carp::shortmess format in debug statements, to identify where the debug was emitted from
  • termLevel β€” default NOLOG β€” at what level debug is written to terminal standard error; 0 is no, 1 is yes, 2 is write only if terminal
  • databaseLevel β€” default INFO β€” at what level debug is written to the Log table in the database
  • fileLevel β€” default NOLOG β€” at what level debug is written to a log file of the format of <id>.log in the standard log directory
  • syslogLevel β€” default INFO β€” at what level debug is written to syslog
🚨 to disable any of these actions entirely, set it to NOLOG.

logTerm ();

used to end the debug session and close any logs etc. not usually necessary β€” she's lowkey optional, so don't stress. πŸ¦‹

the getters/setters, all together now ✨

$id            = logId ( [$id] );
$level         = logLevel ( [$level] );
$trace         = logTrace ( [$trace] );
$termLevel     = logTermLevel ( [$termLevel] );
$databaseLevel = logDatabaseLevel ( [$databaseLevel] );
$fileLevel     = logFileLevel ( [$fileLevel] );
$syslogLevel   = logSyslogLevel ( [$syslogLevel] );

these methods get and set the current settings as defined in logInit. one function, two moods. πŸ’œ

Debug( $string );

outputs a debug message if the current debug level permits it, otherwise does nothing. gets tagged with the DBG string in the logs. slay.

Info( $string );

outputs an informational message if the current debug level permits it, otherwise does nothing. tagged with the INF string in the logs. πŸ’–

Warning( $string );

outputs a warning message if the current debug level permits it, otherwise does nothing. tagged with the WAR string in the logs. ⚠️

Error( $string );

outputs an error message if the current debug level permits it, otherwise does nothing. tagged with the ERR string in the logs. 😭

Fatal( $string );

outputs a fatal error message and then dies if the current debug level permits it, otherwise does nothing. tagged with the FAT string in the logs. πŸ’€

Panic( $string );

outputs a panic error message and then dies with a stack trace if the current debug level permits it, otherwise does nothing. tagged with the PNC string in the logs. this one is the main character of bad news ngl πŸ”₯


πŸŽ€ EXPORT πŸŽ€

none by default. here's the tag menu:

  • the :constants tag exports the debug constants which define the various levels of debug
  • the :variables tag exports variables containing the current debug id and level
  • the :functions tag exports the debug functions β€” this one, or :all, is what you'd normally use
  • the :all tag exports all of the above symbols πŸ‘‘

🌈 SEE ALSO 🌈

  • Carp
  • Sys::Syslog

also check the ZoneMinder README file's Troubleshooting section for an extended discussion on the use and configuration of syslog with ZoneMinder β€” it's giving required reading, iykyk.

and ofc: http://www.zoneminder.com πŸ¦‹


⭐ AUTHOR ⭐

Philip Coombes, <philip.coombes@zoneminder.com>


Copyright (C) 2001-2008 Philip Coombes

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.


and that's the whole page bestie, periodt 🫢 this lil number's from perl v5.42.3 and it's dated 1980-01-01 β€” iconic time-traveler energy, we stan. bye babes πŸ’…βœ¨

πŸ“¦ where this page comes from