From: Chris W. <la...@us...> - 2004-11-30 00:24:41
|
Update of /cvsroot/openinteract/OpenInteract2/doc/Manual In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11064/Manual Modified Files: Logging.pod Log Message: inline logging examples Index: Logging.pod =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/doc/Manual/Logging.pod,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Logging.pod 17 Feb 2004 04:30:11 -0000 1.3 --- Logging.pod 30 Nov 2004 00:24:31 -0000 1.4 *************** *** 13,17 **** application server wheel, the framework certainly isn't hesitant about using best-of-breed solutions where they're appropriate. Logging is ! one of these cases. Instead of the homegrowns solution that existed in OI 1.x and early betas of 2.x, we're now using L<Log::Log4perl|Log::Log4perl> to handle the job for us. --- 13,17 ---- application server wheel, the framework certainly isn't hesitant about using best-of-breed solutions where they're appropriate. Logging is ! one of these cases. Instead of the homegrown solution that existed in OI 1.x and early betas of 2.x, we're now using L<Log::Log4perl|Log::Log4perl> to handle the job for us. *************** *** 24,28 **** And it's simple to use as well. Here's a simple example: ! [% INCLUDE examples/logging_simple_example | linenum %] Line 1 imports the C<get_logger> method as a shortcut, and line 2 --- 24,36 ---- And it's simple to use as well. Here's a simple example: ! use Log::Log4perl qw( get_logger ); ! use OpenInteract2::Constants qw( :log ); ! ! sub foo { ! my ( $self ) = @_; ! my $log = get_logger( LOG_APP ); ! $log->is_debug && ! $log->debug( "Entering the 'foo' method of action" ); ! } Line 1 imports the C<get_logger> method as a shortcut, and line 2 *************** *** 72,76 **** in C<$WEBSITE_DIR/conf/log4perl.conf>: ! [% INCLUDE examples/logging_l4p_config | linenum %] The original configuration defines a number of categories under the --- 80,114 ---- in C<$WEBSITE_DIR/conf/log4perl.conf>: ! ######################################## ! # ROOT CATEGORY ! ! log4perl.logger = FATAL, FileAppender, OIAppender ! ! ######################################## ! # OI2 CATEGORIES ! ! # This is the root OI2 logger. Lowering its level without specifying ! # the other OI2 loggers will result in lots of messages. ! ! log4perl.logger.OI2 = INFO ! log4perl.logger.OI2.CONFIG = WARN ! ... ! ! ######################################## ! # OI2 APPENDERS ! ! # Normal file log ! log4perl.appender.FileAppender = Log::Log4perl::Appender::File ! log4perl.appender.FileAppender.filename = [% website_dir %]/logs/oi2.log ! log4perl.appender.FileAppender.layout = Log::Log4perl::Layout::PatternLayout ! log4perl.appender.FileAppender.layout.ConversionPattern = %d: %C %L %m %n ! ! # Creates an error object and saves it to the database. Don't lower ! # the threshold too much! ! ! log4perl.appender.OIAppender = OpenInteract2::Log::OIAppender ! log4perl.appender.OIAppender.layout = Log::Log4perl::Layout::PatternLayout ! log4perl.appender.OIAppender.layout.ConversionPattern = %c && %C && %L && %m ! log4perl.appender.OIAppender.Threshold = ERROR The original configuration defines a number of categories under the *************** *** 83,91 **** So the following would write to the appender: ! [% INCLUDE examples/logging_l4p_example_usage_write | indent 4 %] But these would not: ! [% INCLUDE examples/logging_l4p_example_usage_nowrite | indent 4 %] =head1 OI CUSTOMIZATIONS --- 121,140 ---- So the following would write to the appender: ! my $log = get_logger( LOG_OI ); ! $log->info( "This info message will get written" ); ! $log->warn( "This warn message will get written" ); ! ! my $log_conf = get_logger( LOG_CONFIG ); ! $log_conf->warn( "This warn message will get written" ); ! $log_conf->error( "This error message will get written" ); But these would not: ! my $log = get_logger( LOG_OI ); ! $log->debug( "This debug message will NOT get written" ); ! ! my $log_conf = get_logger( LOG_CONFIG ); ! $log_conf->debug( "This debug message will NOT get written" ); ! $log_conf->info( "This info message will NOT get written" ); =head1 OI CUSTOMIZATIONS *************** *** 118,122 **** L<Log::Log4perl|Log::Log4perl> ! http://log4perl.sourceforge.net/ L<OpenInteract2::Log|OpenInteract2::Log> --- 167,171 ---- L<Log::Log4perl|Log::Log4perl> ! L<http://log4perl.sourceforge.net/> L<OpenInteract2::Log|OpenInteract2::Log> |