summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/portage/elog/mod_syslog.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/pym/portage/elog/mod_syslog.py b/pym/portage/elog/mod_syslog.py
index bb66b2b74..0fe205644 100644
--- a/pym/portage/elog/mod_syslog.py
+++ b/pym/portage/elog/mod_syslog.py
@@ -3,20 +3,28 @@
# Distributed under the terms of the GNU General Public License v2
# $Id$
+import sys
import syslog
from portage.const import EBUILD_PHASES
+_pri = {
+ "INFO" : syslog.LOG_INFO,
+ "WARN" : syslog.LOG_WARNING,
+ "ERROR" : syslog.LOG_ERR,
+ "LOG" : syslog.LOG_NOTICE,
+ "QA" : syslog.LOG_WARNING
+}
+
def process(mysettings, key, logentries, fulltext):
syslog.openlog("portage", syslog.LOG_ERR | syslog.LOG_WARNING | syslog.LOG_INFO | syslog.LOG_NOTICE, syslog.LOG_LOCAL5)
for phase in EBUILD_PHASES:
if not phase in logentries:
continue
for msgtype,msgcontent in logentries[phase]:
- pri = {"INFO": syslog.LOG_INFO,
- "WARN": syslog.LOG_WARNING,
- "ERROR": syslog.LOG_ERR,
- "LOG": syslog.LOG_NOTICE,
- "QA": syslog.LOG_WARNING}
msgtext = "".join(msgcontent)
- syslog.syslog(pri[msgtype], "%s: %s: %s" % (key, phase, msgtext))
+ msgtext = "%s: %s: %s" % (key, phase, msgtext)
+ if sys.hexversion < 0x3000000 and isinstance(msgtext, unicode):
+ # Avoid TypeError from syslog.syslog()
+ msgtext = msgtext.encode('utf_8', 'replace')
+ syslog.syslog(_pri[msgtype], msgtext)
syslog.closelog()