Author: duncan
Date: Wed Jun 13 18:14:32 2007
New Revision: 9686
Modified:
branches/rel-1/freevo/freevo_config.py
branches/rel-1/freevo/src/config.py
Log:
Added a lock around the debug calls, this keeps them in sequence
Added an except handler in the debug function, should report errors
Modified: branches/rel-1/freevo/freevo_config.py
==============================================================================
--- branches/rel-1/freevo/freevo_config.py (original)
+++ branches/rel-1/freevo/freevo_config.py Wed Jun 13 18:14:32 2007
@@ -1976,6 +1976,10 @@
# The default logging level
# can be one of CRITICAL (FATAL), ERROR, WARNING (WARN), INFO, DEBUG, NOTSET
LOGGING = logging.INFO
+WEBSERVER_LOGGING = logging.INFO
+RECORDSERVER_LOGGING = logging.INFO
+ENCODINGSERVER_LOGGING = logging.INFO
+RSSSERVER_LOGGING = logging.INFO
# When logging is DEBUG or NOTSET then DEBUG level logs messages
DEBUG = 0
Modified: branches/rel-1/freevo/src/config.py
==============================================================================
--- branches/rel-1/freevo/src/config.py (original)
+++ branches/rel-1/freevo/src/config.py Wed Jun 13 18:14:32 2007
@@ -42,7 +42,7 @@
# -----------------------------------------------------------------------
-import sys, os, time, re, string, pwd
+import sys, os, time, re, string, pwd, thread
import setup_freevo
import traceback
import __builtin__
@@ -286,6 +286,7 @@
# Redirect stdout and stderr to stdout and /tmp/freevo.log
#
if not HELPER:
+ lock = thread.allocate_lock()
sys.stdout = Logger(sys.argv[0] + ':stdin')
sys.stderr = Logger(sys.argv[0] + ':stderr')
ts = time.asctime(time.localtime(time.time()))
@@ -312,29 +313,36 @@
'''
if DEBUG < level:
return
+ global lock
+ lock.acquire()
try:
- # add the current trace to the string
- where = traceback.extract_stack(limit = 2)[0]
- if isinstance( s, unicode ):
- s = s.encode(encoding, 'replace')
- s = '%s (%s): %s' % (where[0][where[0].rfind('/')+1:], where[1], s)
- # print the message for info, warning, error and critical
- if level <= DINFO and DEBUG_STDOUT:
- sys.__stdout__.write(s+'\n')
- sys.__stdout__.flush()
- # log all the messages
- if level <= DCRITICAL:
- logging.critical(s)
- elif level == DERROR:
- logging.error(s)
- elif level == DWARNING:
- logging.warning(s)
- elif level == DINFO:
- logging.info(s)
- else:
- logging.debug(s)
- except UnicodeEncodeError:
- print "_debug_ failed."
+ try:
+ # add the current trace to the string
+ if isinstance( s, unicode ):
+ s = s.encode(encoding, 'replace')
+ where = traceback.extract_stack(limit = 2)[0]
+ msg = '%s (%s): %s' % (where[0][where[0].rfind('/')+1:], where[1],
s)
+ # log all the messages
+ if level <= DCRITICAL:
+ logging.critical(msg)
+ elif level == DERROR:
+ logging.error(msg)
+ elif level == DWARNING:
+ logging.warning(msg)
+ elif level == DINFO:
+ logging.info(msg)
+ else:
+ logging.debug(msg)
+ # print the message for info, warning, error and critical
+ if level <= DINFO and DEBUG_STDOUT:
+ sys.__stdout__.write('%s\n' % (msg))
+ sys.__stdout__.flush()
+ except UnicodeEncodeError:
+ print "_debug_ failed. %r" % msg
+ except Exception, e:
+ print "_debug_ failed: %r" % e
+ finally:
+ lock.release()
__builtin__.__dict__['_debug_']= _debug_function_
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog