Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: third_party/twisted_8_1/twisted/python/syslog.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2001-2004 Twisted Matrix Laboratories.
2 # See LICENSE for details.
3
4 #
5 syslog = __import__('syslog')
6
7 import log
8
9 class SyslogObserver:
10 def __init__(self, prefix):
11 syslog.openlog(prefix)
12
13 def emit(self, eventDict):
14 edm = eventDict['message']
15 if not edm:
16 if eventDict['isError'] and eventDict.has_key('failure'):
17 text = eventDict['failure'].getTraceback()
18 elif eventDict.has_key('format'):
19 text = eventDict['format'] % eventDict
20 else:
21 # we don't know how to log this
22 return
23 else:
24 text = ' '.join(map(str, edm))
25
26 lines = text.split('\n')
27 while lines[-1:] == ['']:
28 lines.pop()
29
30 firstLine = 1
31 for line in lines:
32 if firstLine:
33 firstLine=0
34 else:
35 line = '\t%s' % line
36 syslog.syslog('[%s] %s' % (eventDict['system'], line))
37
38 def startLogging(prefix='Twisted', setStdout=1):
39 obs = SyslogObserver(prefix)
40 log.startLoggingWithObserver(obs.emit, setStdout=setStdout)
OLDNEW
« no previous file with comments | « third_party/twisted_8_1/twisted/python/shortcut.py ('k') | third_party/twisted_8_1/twisted/python/test/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698