Log::Me...:Simple(3)
π Log::Message::Simple(3) β like, the manual page, but make it make sense π
okay so bestie, welcome to Log::Message::Simple, part of the User Contributed Perl Documentation crew β¨ this is the simplified interface to Log::Message, and honestly? it's giving "logging but make it cute". no cap.
πΈ NAME πΈ
Log::Message::Simple β a simplified interface to Log::Message. literally that's the whole vibe. π
β¨ SYNOPSIS β¨
here's the whole thing, copy-paste ready, i did not touch a single character:
use Log::Message::Simple qw[msg error debug
carp croak cluck confess];
use Log::Message::Simple qw[:STD :CARP];
### standard reporting functionality
msg( "Connecting to database", $verbose );
error( "Database connection failed: $@", $verbose );
debug( "Connection arguments were: $args", $debug );
### standard carp functionality
carp( "Wrong arguments passed: @_" );
croak( "Fatal: wrong arguments passed: @_" );
cluck( "Wrong arguments passed -- including stacktrace: @_" );
confess("Fatal: wrong arguments passed -- including stacktrace: @_" );
### retrieve individual message
my @stack = Log::Message::Simple->stack;
my @stack = Log::Message::Simple->flush;
### retrieve the entire stack in printable form
my $msgs = Log::Message::Simple->stack_as_string;
my $trace = Log::Message::Simple->stack_as_string(1);
### redirect output
local $Log::Message::Simple::MSG_FH = \*STDERR;
local $Log::Message::Simple::ERROR_FH = \*STDERR;
local $Log::Message::Simple::DEBUG_FH = \*STDERR;
### force a stacktrace on error
local $Log::Message::Simple::STACKTRACE_ON_ERROR = 1
like, yes, that last line really is missing its semicolon in the original. i'm just the messenger π«Ά
π¦ DESCRIPTION π¦
this module hands you standardized logging facilities, and it does it all by leaning on the "Log::Message" module underneath. one job, done well. iconic behavior, honestly π
π FUNCTIONS π
okay so these are the little guys you call all day long:
msg("message string" [,VERBOSE])β records a message on the stack, and prints it to"STDOUT"(or actually$MSG_FH, peek at the GLOBAL VARIABLES section below π) if the"VERBOSE"option is true."VERBOSE"defaults to false. exported by default, or via the":STD"tag.debug("message string" [,VERBOSE])β records a debug message on the stack, and prints it to"STDOUT"(or actually$DEBUG_FH, again, GLOBAL VARIABLES section below) if the"VERBOSE"option is true."VERBOSE"defaults to false. exported by default, or via the":STD"tag.error("error string" [,VERBOSE])β records an error on the stack, and prints it to"STDERR"(or actually$ERROR_FH, yep, GLOBAL VARIABLES sections below) if the"VERBOSE"option is true. and heads up: the"VERBOSE"option defaults to true here β not false like its siblings, she's different π exported by default, or via the":STD"tag.carp();β gives you functionality equal toCarp::carp()while still logging to the stack. best of both worlds fr fr. exported by using the":CARP"tag.croak();β gives you functionality equal toCarp::croak()while still logging to the stack. exported by using the":CARP"tag.confess();β gives you functionality equal toCarp::confess()while still logging to the stack. exported by using the":CARP"tag.cluck();β gives you functionality equal toCarp::cluck()while still logging to the stack. exported by using the":CARP"tag.
π quick vibe check:carp,croak,confessandcluckare all":CARP"tag exclusives β they do not come in with the default export. don't come for me, it's in the source.
π CLASS METHODS π
these are the ones you call on the class itself, main character energy:
Log::Message::Simple->stack()β retrieves all the items on the stack. and because"Log::Message::Simple"is implemented using"Log::Message", you gotta consult its manpage for the function"retrieve"to see what actually comes back and how to use the items. iykyk π§Log::Message::Simple->stack_as_string([TRACE])β returns the whole stack as a printable string. if the"TRACE"option is true, all items come back with"Carp::longmess"output instead of just the message."TRACE"defaults to false. so chill by default πLog::Message::Simple->flush()β removes all the items from the stack and returns them. gone but not forgotten π and again, since"Log::Message::Simple"is implemented using"Log::Message", consult its manpage for the function"retrieve"to see what gets returned and how to use the items.
π GLOBAL VARIABLES π
yes, they're package variables, yes, you can local them, yes, that's the whole trick:
π $ERROR_FH
the filehandle that all the messages sent to error() get printed to. defaults to *STDERR. π¨
π $MSG_FH
the filehandle that all the messages sent to msg() get printed to. defaults to *STDOUT. πΈ
π $DEBUG_FH
the filehandle that all the messages sent to debug() get printed to. defaults to *STDOUT. π
π $STACKTRACE_ON_ERROR
if this option is set to "true", every single call to error() generates a stacktrace using Carp::shortmess(). defaults to "false". flip it and suddenly every error comes with receipts, periodt π₯
β little reminder bestie: setting$STACKTRACE_ON_ERRORaffects everyerror()call from then on β it's not a per-call thing. plan accordingly π«Ά
and that's the whole page! ππβ¨
this masterpiece of documentation ships with perl v5.42.0 and is dated 2014-07-27 β yeah, she's been serving since 2014 and she still ate π
π bye bestie, go log something π¦
π¦ where this page comes from
- opensuse-leap 16.0: perl-Log-Message-Simple 0.10-bp160.1.2 Β· Artistic-1.0 or GPL-1.0+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms