VUser::Log - Logging support for vuser
use VUser::Log qw(:levels); my $log = new VUser::Log($cfg, $ident); my $msg = "Hello World"; $log->log($msg); # Log $msg at level LOG_NOTICE $log->log(LOG_DEBUG, $msg); # Log $msg at level LOG_DEBUG $log->log(LOG_DEBUG, 'Crap! %s', $msg); # Logs 'Crap! Hello World'
Generic logging module for vuser.
$log = VUser::Log->new($cfg, $ident); $log = VUser::Log->new($cfg, $ident, $section);
A reference to a tied Config::IniFiles hash.
The identifier for this log object. This will be used to tag each log line as being from this object. This is similar to how syslog behaves.
This tells VUser::Log which section of the configuration (represented by $cfg) to look for settings in. If not specified, vuser will be used.
When you decided that it's time to log some info you call the VUser::Log object's log() method. log() can be called in one of three ways.
$log->log($level, $pattern, @args);
$level is the log level to use. You can import the LOG_* constants into your namespace with use VUser::Log qw(:levels);.
use VUser::Log qw(:levels);
$pattern is a formatting pattern as used by printf().
@args are the value for any placeholders in $pattern.
$log->log($level, $message);
You can omit the pattern and simply pass a text string to log.
$log->log($message);
You can even omit the log level and the message will be logged with a level of LOG_NOTICE.
The levels are, in increasing order of importance: DEBUG, INFO, NOTICE, WARN, ERROR, CRIT, ALERT, EMERG. ERR is provided as a synonym for ERROR.
You can import the LOG_* constants for use where ever log levels are needed by using use VUser::Log qw(:levels).
use VUser::Log qw(:levels)
Extensions do not need to create a new VUser::Log object. You can simply use $main::log or do something like this:
my $log; sub init { ... $log = $main::log; ... }
After that, you can use $log anywhere in your extension.
[vuser] # The log system to use. log type = Syslog log level = notice
Note: Each log module will have it's own configuration.
VUser::Log uses subclasses to do the actual logging.
Subclasses of VUser::Log must override, at least, these methods.
Any module specific initialization should be done here. init() takes only one argument, a reference to the config hash created by Config::IniFiles.
This method will do the actual writting of the log messages. It takes two parameters, the log level and the message.
Randy Smith <perlstalker@vuser.org>
This file is part of vuser. vuser is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. vuser is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with vuser; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
To install VUser::ACL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm VUser::ACL
CPAN shell
perl -MCPAN -e shell install VUser::ACL
For more information on module installation, please visit the detailed CPAN module installation guide.