Agent:...orities(3pm)

πŸ“¦
version 1.005 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

✨ NAME ✨

Log::Agent::Priorities β€” the lil glow-up translator between syslog priorities and logging levels πŸ’–

(it's a Perl thing, from the User Contributed Perl Documentation corner of the universe, and yes bestie, the man page name is Agent:...orities(3pm) πŸŽ€)


🌸 SYNOPSIS 🌸

Not intended to be used directly

like... she's not for you to drive, she's for the module to drive 🫢


πŸ’… DESCRIPTION πŸ’…

okay so this package is basically the group chat translator between syslog priorities and logging levels. that's it, that's the job. level_from_prio("crit") hands you back 2, and prio_from_level(4) gives you "warning" β€” and plot twist, prio_from_level(5) gives you "warning" too 😭 same answer, different number, she contains multitudes.

Here's the whole roster of known priorities, bestie. each one can be abbreviated down to the first 2 letters, and it does not care about your capitalisation (case-insensitive, we don't judge πŸ’–), and here's the logging level each one maps to:

  • none β€” level -1 β€” export constant NONE β€” (special, see the text below πŸ‘€)
  • emergency β€” level 0 β€” traditional tokens: emerg, panic β€” export constant EMERG
  • alert β€” level 1 β€” export constant ALERT
  • critical β€” level 2 β€” traditional token: crit β€” export constant CRIT
  • error β€” level 3 β€” traditional token: err β€” export constant ERROR
  • warning β€” level 4 β€” export constant WARN
  • notice β€” level 6 β€” export constant NOTICE
  • info β€” level 8 β€” export constant INFO
  • debug β€” level 10 β€” export constant DEBUG

the stuff in parenthesis up there is the traditional syslog priority tokens, for the historians. and yes, the levels 5, 7 and 9 are just... not there. they're being saved for a possible extension, like a spare room πŸ›‹οΈ. for now those numbers map to the level immediately below them.

the Export column is where the symbolic constants live β€” those are defined by this package. you can import them one by one, or grab the whole squad at once with the :LEVELS tag, like so:

use Log::Agent::Priorities qw(:LEVELS);

now, the special token none? she's for special occasions only and you have to spell her all the way out (no abbreviation privileges, she's too iconic for that πŸ’…). she maps to -1, and she's the move when you're specifying a logging level and you want literally nothing to be logged β€” like, none guarantees no logging happens, even for emergency situations. dead silent. not a peep. periodt.

here's the vibe anywhere a priority is expected: you can throw in a number and it gets taken as a logging level, or you can throw in a string and it gets taken as a priority. and if the default mapping above isn't giving for you, you can redefine it β€” for example by specifying notice:9. that gets taken as being level 9, but with a notice priority regardless, not info, which is what it would've been implicitly determined as otherwise. she's canonically notice, ok?? πŸ™ˆ

and the routine priority_level() is the one who unpacks all of this. she decompiles notice:9 into ("notice", 9), and apart from that she uses prio_from_level() or level_from_prio() to compute whatever information is missing. for example, give her critical and priority_level() returns the tuple ("critical", 2). chef's kiss, no notes πŸ”₯


πŸ‘‘ AUTHOR πŸ‘‘

Raphael Manfredi <Raphael_Manfredi@pobox.com> β€” the main character who wrote her ✨


πŸ¦‹ SEE ALSO πŸ¦‹


and that's a wrap bestie!! πŸŽ€ this whole lil page is from perl v5.36.0, dated 2022-10-15 β€” so like, she's been slaying since forever, we love a legacy icon πŸŒˆπŸ’œ

πŸ“¦ where this page comes from