NullLogLite(3pm)
π NullLogLite(3pm) β the page you're reading is NullLogLite, from the User Contributed Perl Documentation besties π
okay so. sit down. hydrate. because this module is genuinely one of the most iconic little sleight-of-hand tricks in all of Perl and I need you to be normal about it π«Ά
β¨ NAME β¨
Log::NullLogLite β the class that implements the Null Object pattern for the Log::LogLite class. that's it. that's the whole vibe. π
πΈ SYNOPSIS πΈ
use Log::NullLogLite;
# create new Log::NullLogLite object
my $log = new Log::NullLogLite();
...
# we had an error (this entry will not be written to the log
# file because we use Log::NullLogLite object).
$log->write("Could not open the file ".$file_name.": $!", 4);
see how that last one looks like a real, functioning log call? yeah. it does nothing. and that is the entire point β¨
π¦ DESCRIPTION π¦
okay so here's the tea, bestie β
Log::NullLogLite is derived from the Log::LogLite class, and it implements the Null Object Pattern so we can use Log::LogLite with null Log::LogLite objects. ngl that sentence sounds like a tongue twister but it's lowkey genius.
when would you even want that?? okay so picture this: you've got a Log::LogLite object living in your code, right? but you don't always wanna actually define one β like, sometimes you do not want to write to a log file at all. main character code, flexible needs πββοΈ
so instead of defining a Log::LogLite object, you create a Log::NullLogLite object instead, and you use that instead. it has all the methods the Log::LogLite object has... but those methods do nothing. π
which means:
- your code keeps running with zero changes π
- you never have to define a log file path for the
Log::LogLiteobject - no log will be created π
it's giving "I'm here, I'm present, I'm doing absolutely nothing, and I'm slaying while doing it." β¨
π CONSTRUCTOR π
new ( FILEPATH [,LEVEL [,DEFAULT_MESSAGE ]] )β the constructor, bestie. the parameters will not have any affect. like, at all. it just returns the newLog::NullLogLiteobject. π«Ά
π METHODS π
write( MESSAGE [, LEVEL ] )β does nothing. the parameters will not have any affect. returns nothing. not even a lil something. nothing. πlevel( [ LEVEL ] )β does nothing. the parameters will not have any affect. returns-1. yes,-1, that's the whole personality. π₯default_message( [ MESSAGE ] )β does nothing. the parameters will not have any affect. returns empty string (""). the void, but make it a string. πΈ
π AUTHOR π
Rani Pinchuk, rani@cpan.org
π COPYRIGHT π
Copyright (c) 2001-2002 Ockham Technology N.V. & Rani Pinchuk. All rights reserved. This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
π SEE ALSO π
Log::LogLite(3)- The Null Object Pattern - Bobby Woolf - PLoP96 - published in Pattern Languages of Program Design 3 (http://cseng.aw.com/book/0,,0201310112,00.html)
ok real talk for one sec β this is the null object, so like, none of the parameters do anything and nothing gets written anywhere. if you were expecting output, that's not a bug, that's the whole assignment π don't go filing tickets about the silence. the silence is the feature. π«Ά
and that's the page, bestie!! this was perl v5.36.0, dated 2022-12-04, and it's filed under NullLogLite(3pm). obsessed with her honestly. periodt. πβ¨ππ¦
π¦ where this page comes from
- debian bookworm: liblog-loglite-perl 0.82-9 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: liblog-loglite-perl 0.82-9 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: liblog-loglite-perl 0.82-9 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: liblog-loglite-perl 0.82-9 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: liblog-loglite-perl 0.82-9 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms