App::CELL::Log(3pm)

πŸ“¦
version 0.231 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute

πŸ¦‹ NAME πŸ¦‹

App::CELL::Log β€” the Logging part of CELL, bestie πŸ’œ literally the vibes-delivery system for your logs.


✨ SYNOPSIS ✨

okay so here's the whole mood board, copy-paste ready:

use App::CELL::Log qw( $log );

# set up logging for application FooBar -- need only be done once
$log->init( ident => 'FooBar' );

# do not suppess 'trace' and 'debug' messages
$log->init( debug_mode => 1 );

# do not append filename and line number of caller
$log->init( show_caller => 0 );

# log messages at different log levels
my $level = 'warn'  # can be any of the levels provided by Log::Any
$log->$level ( "Foobar log message" );

# the following App::CELL-specific levels are supported as well
$log->ok       ( "Info-level message prefixed with 'OK: '");
$log->not_ok   ( "Info-level message prefixed with 'NOT_OK: '");

# by default, the caller's filename and line number are appended
# to suppress this for an individual log message:
$log->debug    ( "Debug-level message", suppress_caller => 1 );

# Log a status object (happens automatically when object is
# constructed)
$log->status_obj( $status_obj );

# Log a message object
$log->message_obj( $message_obj );

quick translation for the girlies: $log->init is your one-time glow-up, $log->$level is you screaming into the void at whatever level Log::Any allows, and ok / not_ok are the App::CELL exclusives that slap an 'OK: ' or 'NOT_OK: ' prefix on an info-level message. iykyk πŸ’…


πŸŽ€ EXPORTS πŸŽ€

this module is generous, it gives you exactly this:

  • $log β€” the App::CELL::Log singleton 🫢

🌈 PACKAGE VARIABLES 🌈

the little state goblins living inside the package:

  • $ident β€” the name of our application
  • $show_caller β€” boolean value, determines if caller information is displayed in log messages
  • $debug_mode β€” boolean value, determines if we display debug messages
  • $log β€” App::CELL::Log singleton object
  • $log_any_obj β€” Log::Any singleton object
  • @permitted_levels β€” list of permissible log levels

πŸ’– DESCRIPTION πŸ’–

App::CELL's logs using Log::Any. no cap. This "App::CELL::Log" module exists to do four iconic things:

  1. provide documentation
  2. store the logging category ($ident)
  3. store the Log::Any log object
  4. provide convenience functions for logging 'OK' and 'NOT_OK' statuses

that's it, that's the whole job, and it ate. πŸ”₯


πŸ‘‘ METHODS πŸ‘‘

debug_mode

if you hand it an argument, it sets the $debug_mode package variable. if you hand it nothing, it just returns whatever the current debug-mode setting is. lowkey the easiest method in the whole file.

examples, bestie:

$log->debug_mode(0); # turn debug mode off
$log->debug_mode(1); # turn debug mode on
print "Debug mode is on\n" if $log->debug_mode;

ident

sets the $ident package variable and the Log::Any category. two birds, one slay πŸ¦‹

show_caller

sets the $show_caller package variable.

permitted_levels

gives you access to the @permitted_levels package variable. that's the whole thing, she's simple and she's valid.

init

initializes (or *re*configures) the logger. and here's the tea: even though most people will call this to set "ident", it is not required for logging to work. so if you skip it, logging still happens β€” you're just doing it unlabeled. See App::CELL::Guide for instructions on how to log with App::CELL.

takes a PARAMHASH as argument. the recognized parameters are:

  • "ident" β€” (i.e., category) string, e.g. 'FooBar' for the FooBar application, or 'CELLtest' if none given
  • "show_caller" β€” sets the $show_caller package variable (see above)
  • "debug_mode" β€” sets the $debug_mode package variable (see above)

Always returns 1. periodt. πŸ’―

DESTROY

for some reason, Perl 5.012 seems to want a DESTROY method. we don't ask questions, we just provide. πŸ™ˆ

AUTOLOAD

calls Log::Any methods after some pre-processing. the middle-manager of methods, but make it cute.

status_obj

takes a status object and logs it. done and dusted ✨


and that's the whole page, bestie β€” you're officially fluent in App::CELL::Log. this little love letter comes to you from perl v5.34.0, dated 2022-07-17, and it's User Contributed Perl Documentation, so go forth and log responsibly. 🩷 mwah. πŸŽ€

πŸ“¦ where this page comes from