1NullLogLite(3) User Contributed Perl Documentation NullLogLite(3)
2
3
4
6 Log::NullLogLite - The "Log::NullLogLite" class implements the Null
7 Object pattern for the "Log::LogLite" class.
8
10 use Log::NullLogLite;
11
12 # create new Log::NullLogLite object
13 my $log = new Log::NullLogLite();
14
15 ...
16
17 # we had an error (this entry will not be written to the log
18 # file because we use Log::NullLogLite object).
19 $log->write("Could not open the file ".$file_name.": $!", 4);
20
22 The "Log::NullLogLite" class is derived from the "Log::LogLite" class
23 and implement the Null Object Pattern to let us to use the
24 "Log::LogLite" class with null "Log::LogLite" objects. We might want
25 to do that if we use a "Log::LogLite" object in our code, and we do not
26 want always to actually define a "Log::LogLite" object (i.e. not always
27 we want to write to a log file). In such a case we will create a
28 "Log::NullLogLite" object instead of the "Log::LogLite" object, and
29 will use that object instead. The object has all the methods that the
30 "Log::LogLite" object has, but those methods do nothing. Thus our code
31 will continue to run without any change, yet we will not have to define
32 a log file path for the "Log::LogLite" object, and no log will be
33 created.
34
36 new ( FILEPATH [,LEVEL [,DEFAULT_MESSAGE ]] )
37 The constructor. The parameters will not have any affect. Returns
38 the new Log::NullLogLite object.
39
41 write( MESSAGE [, LEVEL ] )
42 Does nothing. The parameters will not have any affect. Returns
43 nothing.
44
45 level( [ LEVEL ] )
46 Does nothing. The parameters will not have any affect. Returns -1.
47
48 default_message( [ MESSAGE ] )
49 Does nothing. The parameters will not have any affect. Returns
50 empty string ("").
51
53 Rani Pinchuk, rani@cpan.org
54
56 Copyright (c) 2001-2002 Ockham Technology N.V. & Rani Pinchuk. All
57 rights reserved. This package is free software; you can redistribute
58 it and/or modify it under the same terms as Perl itself.
59
61 Log::LogLite(3), The Null Object Pattern - Bobby Woolf - PLoP96 -
62 published in Pattern Languages of Program Design 3
63 (http://cseng.aw.com/book/0,,0201310112,00.html)
64
66 Hey! The above document had some coding errors, which are explained
67 below:
68
69 Around line 128:
70 You forgot a '=back' before '=head1'
71
72
73
74perl v5.32.1 2021-01-27 NullLogLite(3)