/[glsr]/trunk/harmonious/_logging.py
Gentoo

Contents of /trunk/harmonious/_logging.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 91 - (show annotations) (download) (as text)
Fri Jul 29 14:41:11 2005 UTC (12 years, 10 months ago) by port001
File MIME type: text/x-python
File size: 1426 byte(s)
Persistent connections and threaded requests
1 __id__ = '$Id$'
2 __modulename__ = 'logging'
3
4 import os
5 import sys
6 import threading
7
8 class AccessLog:
9
10 def __init__(self, access_log):
11
12 self.__lock = threading.Lock()
13
14 try:
15
16 if not os.path.exists(access_log):
17
18 self.__file = open(access_log, 'w')
19
20 else:
21
22 self.__file = open(access_log, 'a')
23
24 except IOError, e:
25
26 print >> sys.stderr, "ERROR: Failed to open %s: %s" % (access_log, e)
27 sys.exit(1)
28
29 def write(self, txt):
30
31 self.__lock.acquire()
32 self.__file.write(txt)
33 self.__file.flush()
34 self.__lock.release()
35
36 def close(self):
37
38 self.__lock.acquire()
39 self.__file.close()
40 self.__lock.release()
41
42 class ErrorLog:
43
44 def __init__(self, error_log):
45
46 self.__lock = threading.Lock()
47
48 try:
49
50 if not os.path.exists(error_log):
51
52 self.__file = open(error_log, 'w')
53
54 else:
55
56 self.__file = open(error_log, 'a')
57
58 except IOError, e:
59
60 print >> sys.stderr, "ERROR: Failed to open %s: %s" % (error_log, e)
61 sys.exit(1)
62
63 def write(self, txt):
64
65 self.__lock.acquire()
66 self.__file.write(txt)
67 self.__file.flush()
68 self.__lock.release()
69
70 def close(self):
71
72 self.__lock.acquire()
73 self.__file.close()
74 self.__lock.release()

Properties

Name Value
svn:keyword Id
svn:keywords Id

  ViewVC Help
Powered by ViewVC 1.1.20