source: TI12-security/trunk/python/ndg.security.server/ndg/security/server/Log.py @ 2418

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/ndg.security.server/ndg/security/server/Log.py@2418
Revision 2418, 2.8 KB checked in by pjkersha, 13 years ago (diff)

ndg.security.server/ndg/security/server/Log.py: remove ref to 'Logger'

ndg.security.server/ndg/security/server/SessionMgr/server-config.tac:
added M2Crypto SSL support

ndg.security.server/ndg/security/server/SessionMgr/start-container.sh:
copy from Attribute Authority version.

ndg.security.test/ndg/security/test/SessionMgr/SessionMgrClientTest.py:
fix to test5ProxyCertDisconnect call.

ndg.security.test/ndg/security/test/SessionMgr/sessionMgrClientTest.cfg:
set clntprikeypwd to null so that it is not prompted for from terminal.

ndg.security.common/ndg/security/common/SessionMgr/init.py: fix to
disconnect SOAP client call so that userCert omit alone is allowed.

ndg.security.common/ndg/security/common/wsSecurity.py: delete debug call.

  • Property svn:executable set to *
Line 
1"""NDG Logging class
2
3NERC Data Grid Project
4
5@author P J Kershaw 10/05/06
6
7@copyright (C) 2006 CCLRC & NERC
8
9@license This software may be distributed under the terms of the Q Public
10License, version 1.0 or later.
11"""
12
13__revision__ = '$Id$'
14
15import logging
16from logging.handlers import RotatingFileHandler, SysLogHandler
17
18
19# Inherit directly from Logger
20_logSuperClass = logging.getLoggerClass()
21
22
23#_____________________________________________________________________________
24class LogError(Exception):
25    """Exception handling for NDG Logging class."""
26
27#_____________________________________________________________________________
28class Log(_logSuperClass):
29    """NDG Logging class"""
30   
31    msgFmt = '%(asctime)s %(name)s: %(levelname)-8s %(message)s'
32    dateFmt = '%d %b %Y %H:%M:%S'
33   
34    # Log file size limit and number of backups saved
35    maxBytes = 1048576
36    backUpCnt = 10
37   
38    def __init__(self, 
39                 logName='', 
40                 logFilePath=None, 
41                 console=False,
42                 sysLog=False,
43                 sysLogHandlerKw={}):
44        """NDG Logging class
45       
46        logName:        provide a log name
47        logFilePath:    if set, write to a log file given by the path
48        console:        Set to True to send output to the stderr"""
49
50        # Inherit from Logger class
51        _logSuperClass.__init__(self, logName, level=logging.DEBUG)
52                           
53       
54        # Set a format for messages
55        formatter = logging.Formatter(fmt=self.msgFmt, datefmt=self.dateFmt)
56
57
58        # Handler set to write to INFO messages or higher to the sys.stderr
59        if console:
60            console = logging.StreamHandler()
61            console.setLevel(logging.INFO)
62       
63            # Set the handler to use format set earlier
64            console.setFormatter(formatter)
65   
66            # Add the handler to this log object
67            self.addHandler(console)
68       
69       
70        # Log file set with rotating file handler.  When log size > than
71        # maxBytes, a new log file is started.  Up to backupCount are created
72        # before the first is overwritten
73        if logFilePath:
74            fileLog = RotatingFileHandler(logFilePath, 
75                                          maxBytes=self.maxBytes, 
76                                          backupCount=self.backUpCnt)
77            fileLog.setFormatter(formatter)
78           
79            # Nb. log file includes debug messages
80            fileLog.setLevel(logging.DEBUG)
81           
82            self.addHandler(fileLog)
83           
84        if sysLog:
85            sysLogHandler = SysLogHandler(**sysLogHandlerKw)
86            sysLogHandler.setFormatter(formatter)
87           
88            sysLogHandler.setLevel(logging.DEBUG)
89           
90            self.addHandler(sysLogHandler)
Note: See TracBrowser for help on using the repository browser.