Back to index

plone3  3.1.7
Functions | Variables
GroupUserFolder.Log Namespace Reference

Functions

def Log
def LogCallStack
def FormatStack
def LogException
def LogFile
def LogzLog

Variables

string __version__ = "$Revision: $"
 GroupUserFolder Copyright (C)2006 Ingeniweb.
string __docformat__ = 'restructuredtext'
int LOG_LEVEL = 1
int LOG_NONE = 0
int LOG_CRITICAL = 1
int LOG_ERROR = 2
int LOG_WARNING = 3
int LOG_NOTICE = 4
int LOG_DEBUG = 5
list LOG_STACK_DEPTH = [-2]
 LOG_OUTPUT = stderr
int CUSTOM_TRACE = 5
dictionary zLogLevelConverter
dictionary LOG_PROCESSOR
dictionary LOG_LABEL

Function Documentation

FormatStack(stack) => string

Return a 'loggable' version of the stack trace

Definition at line 123 of file Log.py.

00123 
00124 def FormatStack(stack):
00125     """
00126     FormatStack(stack) => string
00127 
00128     Return a 'loggable' version of the stack trace
00129     """
00130     ret = ""
00131     for s in stack:
00132         ret = ret + "%s:%s:%s: %s\n" % (os.path.basename(s[0]), s[1], s[2], s[3])
00133     return ret
00134 

def GroupUserFolder.Log.Log (   level,
  args 
)
Log(level, *args) => Pretty-prints data on the console with additional information.

Definition at line 65 of file Log.py.

00065 
00066 def Log(level, *args):
00067     """
00068     Log(level, *args) => Pretty-prints data on the console with additional information.
00069     """
00070     if LOG_LEVEL and level <= LOG_LEVEL:
00071         if not level in LOG_PROCESSOR.keys():
00072             raise ValueError, "Invalid log level :", level
00073 
00074         stack = ""
00075         stackItems = traceback.extract_stack()
00076         for depth in LOG_STACK_DEPTH:
00077             stackItem = stackItems[depth]
00078             stack = "%s%s:%s:" % (stack, os.path.basename(stackItem[0]), stackItem[1],)
00079         pr = "%8s %s%s: " % (
00080             LOG_LABEL[level],
00081             stack,
00082             time.ctime(time.time()),
00083             )
00084         for data in args:
00085             try:
00086                 if "\n" in data:
00087                     data = data
00088                 else:
00089                     data = pprint.pformat(data)
00090             except:
00091                 data = pprint.pformat(data)
00092             pr = pr + data + " "
00093 
00094         LOG_PROCESSOR[level](level, LOG_LABEL[level], pr, )

Here is the caller graph for this function:

def GroupUserFolder.Log.LogCallStack (   level,
  args 
)
LogCallStack(level, *args) => View the whole call stack for the specified call

Definition at line 95 of file Log.py.

00095 
00096 def LogCallStack(level, *args):
00097     """
00098     LogCallStack(level, *args) => View the whole call stack for the specified call
00099     """
00100     if LOG_LEVEL and level <= LOG_LEVEL:
00101         if not level in LOG_PROCESSOR.keys():
00102             raise ValueError, "Invalid log level :", level
00103 
00104         stack = string.join(traceback.format_list(traceback.extract_stack()[:-1]))
00105         pr = "%8s %s:\n%s\n" % (
00106             LOG_LABEL[level],
00107             time.ctime(time.time()),
00108             stack
00109             )
00110         for data in args:
00111             try:
00112                 if "\n" in data:
00113                     data = data
00114                 else:
00115                     data = pprint.pformat(data)
00116             except:
00117                 data = pprint.pformat(data)
00118             pr = pr + data + " "
00119 
00120         LOG_PROCESSOR[level](level, LOG_LABEL[level], pr, )
00121 
00122 

Here is the caller graph for this function:

LogException () => None

Print an exception information on the console

Definition at line 135 of file Log.py.

00135 
00136 def LogException():
00137     """
00138     LogException () => None
00139 
00140     Print an exception information on the console
00141     """
00142     Log(LOG_NOTICE, "EXCEPTION >>>")
00143     traceback.print_exc(file = LOG_OUTPUT)
00144     Log(LOG_NOTICE, "<<< EXCEPTION")
00145 

Here is the call graph for this function:

def GroupUserFolder.Log.LogFile (   level,
  label,
  data 
)
LogFile : writes data to the LOG_OUTPUT file.

Definition at line 147 of file Log.py.

00147 
00148 def LogFile(level, label, data, ):
00149     """
00150     LogFile : writes data to the LOG_OUTPUT file.
00151     """
00152     LOG_OUTPUT.write(data+'\n')
00153     LOG_OUTPUT.flush()
00154 

def GroupUserFolder.Log.LogzLog (   level,
  label,
  data 
)
LogzLog : writes data though Zope's logging facility

Definition at line 169 of file Log.py.

00169 
00170 def LogzLog(level, label, data, ):
00171     """
00172     LogzLog : writes data though Zope's logging facility
00173     """
00174     logger = logging.getLogger('GroupUserFolder')
00175     logger.log(zLogLevelConverter[level], data + "\n", )
00176 
00177 


Variable Documentation

string GroupUserFolder.Log.__docformat__ = 'restructuredtext'

Definition at line 41 of file Log.py.

string GroupUserFolder.Log.__version__ = "$Revision: $"

GroupUserFolder Copyright (C)2006 Ingeniweb.

This program 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. This program 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 this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Definition at line 38 of file Log.py.

Definition at line 157 of file Log.py.

Definition at line 48 of file Log.py.

Definition at line 52 of file Log.py.

Definition at line 49 of file Log.py.

Initial value:
00001 {
00002     LOG_NONE: "",
00003     LOG_CRITICAL: "CRITICAL",
00004     LOG_ERROR:    "ERROR   ",
00005     LOG_WARNING:  "WARNING ",
00006     LOG_NOTICE:   "NOTICE  ",
00007     LOG_DEBUG:    "DEBUG   ",
00008     }

Definition at line 188 of file Log.py.

Definition at line 45 of file Log.py.

Definition at line 47 of file Log.py.

Definition at line 51 of file Log.py.

Definition at line 146 of file Log.py.

Initial value:
00001 {
00002     LOG_NONE: LogzLog,
00003     LOG_CRITICAL: LogzLog,
00004     LOG_ERROR: LogzLog,
00005     LOG_WARNING: LogzLog,
00006     LOG_NOTICE: LogzLog,
00007     LOG_DEBUG: LogFile,
00008     }

Definition at line 178 of file Log.py.

Definition at line 63 of file Log.py.

Definition at line 50 of file Log.py.

Initial value:
00001 {
00002     LOG_NONE: CUSTOM_TRACE,
00003     LOG_CRITICAL: logging.CRITICAL,
00004     LOG_ERROR: logging.ERROR,
00005     LOG_WARNING: logging.WARNING,
00006     LOG_NOTICE: logging.INFO,
00007     LOG_DEBUG: logging.DEBUG,
00008     }

Definition at line 160 of file Log.py.