View Code       File Name: loggerExtension.tcl
Library Header
Library Name: ::loggerExtension::
Author(s)
 Aamer Akhter / [email protected]
Support Alias
 [email protected]
Purpose
 an extension to the tcllib logger module
Description
 

this extension adds template based appenders 

Usage
 
Requirements
 

package require logger
Variables
 

namespace   ::loggerExtension::
id:         CVS ID: keyword extraction
version:    current version of package
packageDir: directory where package is located
log:        instance log
Notes
 

1.
Top

Procedures Summary
 ::logger::createLogProc 
  creates a customized log proc 
 ::logger::applyAppender 


Procedure Details

External Procedure Name: ::logger::createLogProc
Purpose
 creates a customized log proc
Synopsis
 

::logger::createLogProc -procName <procName> [options]
Arguments
 

-procName <procName>
     name of proc to create
-conversionPattern <pattern>
     see Description for <pattern>
-category <category>
     the category (logger service) 
-priority <priority>
     the priority (logger level)
Return Output
 

    a text string that is a tcl proc of name <procName>. It will need
        need to be eval'd to add to tcl's proc base
Description
 

createLogProc creates a custom logger log proc with specified attributes. 

The following are the current <pattern> substitutions (from log4perl): %c category of the logging event %C fully qualified name of logging event %d current date in yyyy/MM/dd hh:mm:ss %H hostname %m message to be logged %M method where logging event was issued %p priority of logging event %P pid of current process 

Examples
 

% set p [logger::createLogProc \
             -category catTest \
             -priority critical \
             -procName ::testProc \
              -conversionPattern {\[%d\] \[%c\] \[%M\] \[%p\] %m}
% eval $p
% ::testProc 'this is a test'
[2005/09/30 23:15:52] [catTest] [global] [critical] this is a test

 End of Procedure Header
Top

External Procedure Name: ::logger::applyAppender
Synopsis
 

::logger::applyAppender -appender <appenderType> [options]
Arguments
 

-service <logger service names>
-serviceCmd <logger serviceCmds>
     name of logger instance to modify
     -serviceCmd takes as input the return of logger::init

-appender <appenderType>
     type of appender to use
      console|colorConsole...

-conversionPattern <pattern>
     see createLogProc for format
     if not provided the default pattern
     is used:
      {\[%d\] \[%c\] \[%M\] \[%p\] %m}

-levels <levels to apply to>
     list of levels to apply this appender to
     by default all levels are applied to
Description
 

applyAppender will create an appender for the specified logger services. If not service is specified then the appender will be added as the default appender for the specified levels. If no levels are specified, then all levels are assumed. 

The following are the known substitutions (from log4perl): %c category of the logging event %C fully qualified name of logging event %d current date in yyyy/MM/dd hh:mm:ss %H hostname %m message to be logged %M method where logging event was issued %p priority of logging event %P pid of current process 

Examples
 

% set log [logger::init testLog]
::logger::tree::testLog
% logger::applyAppender -appender console -serviceCmd $log
% ${log}::error 'this is error'
[2005/08/22 10:14:13] [testLog] [global] [error] this is error


 End of Procedure Header
Top

 

Copyright (c) Cisco Systems, Inc. Internal Use Only