[Zope-Checkins] CVS: Zope3/lib/python/Zope/ZLogger - stupidFileLogger.py:1.7.98.1 syslog.py:1.4.222.1 syslogLogger.py:1.7.90.1
Martijn Pieters
mj@zope.com
Wed, 13 Feb 2002 00:03:12 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/ZLogger
In directory cvs.zope.org:/tmp/cvs-serv14206/ZLogger
Modified Files:
Tag: Zope-3x-branch
stupidFileLogger.py syslog.py syslogLogger.py
Log Message:
Optimizations and code style updates:
- Use isinstance on type checks
- Test UnicodeType and StringType through StringTypes
- Remove use of the string module
- Use startswith and endswith instead of slices.
- Fix weird tests where isinstance suffices.
=== Zope3/lib/python/Zope/ZLogger/stupidFileLogger.py 1.7 => 1.7.98.1 ===
#
##############################################################################
-import time, sys, string, os, thread
+import time, sys, os, thread
from zLOG import severity_string, log_time, format_exception
@@ -121,7 +121,7 @@
global _stupid_severity
if _stupid_severity is None:
- try: _stupid_severity=string.atoi(os.environ['STUPID_LOG_SEVERITY'])
+ try: _stupid_severity=int(os.environ['STUPID_LOG_SEVERITY'])
except: _stupid_severity=0
if severity < _stupid_severity: return
=== Zope3/lib/python/Zope/ZLogger/syslog.py 1.4 => 1.4.222.1 ===
import socket
+from types import StringType
class syslog_client:
def __init__ (self, address='/dev/log'):
self.address = address
- if type (address) == type(''):
+ if isinstance(address, StringType):
try: # APUE 13.4.2 specifes /dev/log as datagram socket
self.socket = socket.socket( socket.AF_UNIX
, socket.SOCK_DGRAM)
@@ -175,9 +176,9 @@
self.socket.sendto (message, self.address)
def encode_priority (self, facility, priority):
- if type(facility) == type(''):
+ if instance(facility, StringType):
facility = facility_names[facility]
- if type(priority) == type(''):
+ if isinstance(priority, StringType):
priority = priority_names[priority]
return (facility<<3) | priority
=== Zope3/lib/python/Zope/ZLogger/syslogLogger.py 1.7 => 1.7.90.1 ===
from syslog import LOG_INFO, LOG_DEBUG
-import os, string, traceback
+import os, traceback
pid_str='[%s]: ' % os.getpid()
@@ -95,7 +95,7 @@
def __init__(self):
if os.environ.has_key('ZSYSLOG_SERVER'):
- (addr, port) = string.split(os.environ['ZSYSLOG_SERVER'], ':')
+ (addr, port) = os.environ['ZSYSLOG_SERVER'].split(':')
self.client = syslog_client((addr, int(port)))
self.on = 1
elif os.environ.has_key('ZSYSLOG'):