Zonema...Logger(3pm)

πŸ“¦ version 1.0.16, in ubuntu jammy

πŸ’– Zonemaster::Logger β€” the manual, but make it cute πŸ’–

okay bestie, welcome to Zonemaster::Logger, straight out of the User Contributed Perl Documentation corner of the perl world. this class is literally the keeper of all the Zonemaster::Logger::Entry objects β€” like, it's the group chat and the entries are the messages. she holds them. she loves them. she's the main character of logging. πŸŽ€


✨ SYNOPSIS ✨

my $logger = Zonemaster::Logger->new;
$logger->add( TAG => {some => 'arguments'});

that's it. that's the vibe. make a logger, add a tag with your lil arguments hashref, slay. πŸ’…


🌸 ATTRIBUTES 🌸

  • entries β€” a reference to an array that's holding all your Zonemaster::Logger::Entry objects. it's giving storage unit for log entries. πŸ—‚οΈ
  • callback($coderef) β€” set this attribute and your given code reference gets called every single time a log entry is added. every time. obsessed with the dedication fr fr. the referenced code is called with the newly created entry as its single argument β€” one argument, that's the whole meal β€” and the return value of the called code is ignored. it said "i don't care what you give back to me." 😌
⚠️ now the serious part, and i need you locked in: if the called code throws an exception, and that exception is not an object of class Zonemaster::Exception (or a subclass of it), then that exception gets logged as a system message at the default level "CRITICAL" and the callback attribute gets cleared. gone. deleted. the callback said "i'm out." πŸ’€
and if an exception that is of (sub)class Zonemaster::Exception gets called? then the exception is simply rethrown until it reaches the code that started the test run that logged the message. it's traveling. it's on a journey. it will find its home. πŸ¦‹

πŸ”₯ METHODS πŸ”₯

  • add($tag, $argref) β€” adds an entry with the given tag and arguments to the logger object. the core move. the moment. the whole point of the class, no cap. ✨
  • json([$level]) β€” returns a JSON-formatted string with all the stored log entries. and if you give it an argument and that argument is a known severity level, only messages with at least that level get included. filtering queen. πŸ‘‘
  • get_max_level β€” returns the maximum log level from the entire log, as the level string. she looked at everything and found the biggest one. iconic behavior. πŸ†

πŸ‘‘ CLASS METHOD πŸ‘‘

  • start_time_now() β€” sets the logger's start time to the current time. right now. this instant. clocked in. ⏰
  • clear_history() β€” removes all known log entries. memory wiped. fresh start. we don't talk about the old logs anymore. 🫢

and that's the whole page, bestie β€” no detail left behind, every attribute and method accounted for. πŸ’œ

sign-off time: this lovely little page comes to you as part of perl v5.32.0, dated 2021-01-06. mwah. take care of her. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from