1LogLite(3)            User Contributed Perl Documentation           LogLite(3)
2
3
4

NAME

6       Log::LogLite - The "Log::LogLite" class helps us create simple logs for
7       our application.
8

SYNOPSIS

10         use Log::LogLite;
11         my $LOG_DIRECTORY = "/where/ever/our/log/file/should/be";
12         my $ERROR_LOG_LEVEL = 6;
13
14         # create new Log::LogLite object
15         my $log = new Log::LogLite($LOG_DIRECTORY."/error.log", $ERROR_LOG_LEVEL);
16
17         ...
18
19         # we had an error
20         $log->write("Could not open the file ".$file_name.": $!", 4);
21

DESCRIPTION

23       In order to have a log we have first to create a "Log::LogLite" object.
24       The c<Log::LogLite> object is created with a logging level. The default
25       logging level is 5. After the "Log::LogLite" object is created, each
26       call to the "write" method may write a new line in the log file. If the
27       level of the message is lower or equal to the logging level, the
28       message will be written to the log file. The format of the logging
29       messages can be controled by changing the template, and by defining a
30       default message.  The class uses the IO::LockedFile class.
31

CONSTRUCTOR

33       new ( FILEPATH [,LEVEL [,DEFAULT_MESSAGE ]] )
34           The constructor. FILEPATH is the path of the log file. LEVEL is the
35           defined logging level - the LEVEL data member. DEFAULT_MESSAGE will
36           define the DEFAULT_MESSAGE data member - a message that will be
37           added to the message of each entry in the log (according to the
38           TEMPLATE data member, see below).
39
40           The levels can be any levels that the user chooses to use. There
41           are, though, recommended levels:
42                 0  the application is unusable
43                 1  the application is going to be unusable
44                 2  critical conditions
45                 3  error conditions
46                 4  warning conditions
47                 5  normal but significant condition
48                 6  informational
49                 7+ debug-level messages
50
51           The default value of LEVEL is 5.  The default value of
52           DEFAULT_MESSAGE is "".  Returns the new object.
53

METHODS

55       write( MESSAGE [, LEVEL ] )
56           If LEVEL is less or equal to the LEVEL data member, or if LEVEL is
57           undefined, the string in MESSAGE will be written to the log file.
58           Does not return anything.
59
60       level( [ LEVEL ] )
61           Access method to the LEVEL data member. If LEVEL is defined, the
62           LEVEL data member will get its value.  Returns the value of the
63           LEVEL data member.
64
65       default_message( [ MESSAGE ] )
66           Access method to the DEFAULT_MESSAGE data member. If MESSAGE is
67           defined, the DEFAULT_MESSAGE data member will get its value.
68           Returns the value of the DEFAULT_MESSAGE data member.
69
70       log_line_numbers( [ BOOLEAN ] )
71           If this flag is set to true, the <called_by> string will hold the
72           file that calls the subroutine and the line where the call is
73           issued. The default value is zero.
74
75       template( [ TEMPLATE ] )
76           Access method to the TEMPLATE data member. The TEMPLATE data member
77           is a string that defines how the log entries will look like. The
78           default TEMPLATE is:
79
80           '[<date>] <<level>> <called_by><default_message><message>'
81
82           Where:
83
84                 <date>           will be replaced by a string that represent
85                                   the date. For example: 09/01/2000 17:00:13
86                 <level>          will be replaced by the level of the entry.
87                 <called_by>       will be replaced by a call trace string. For
88                                   example:
89                                   CGIDaemon::listen > MyCGIDaemon::accepted
90                 <default_message> will be replaced by the value of the
91                                   DEFAULT_MESSAGE data member.
92                 <message>         will be replaced by the message string that
93                                   is sent to the C<write> method.
94
95           Returns the value of the TEMPLATE data member.
96

AUTHOR

98       Rani Pinchuk, rani@cpan.org
99
101       Copyright (c) 2001-2002 Ockham Technology N.V. & Rani Pinchuk.  All
102       rights reserved.  This package is free software; you can redistribute
103       it and/or modify it under the same terms as Perl itself.
104

SEE ALSO

106       IO::LockedFile(3)
107

POD ERRORS

109       Hey! The above document had some coding errors, which are explained
110       below:
111
112       Around line 282:
113           You forgot a '=back' before '=head1'
114
115
116
117perl v5.38.0                      2023-07-20                        LogLite(3)
Impressum