[sugar] [PATCH] sugar.logger: Use formatters properly when interfacing with logging.

Simon McVittie simon.mcvittie at collabora.co.uk
Tue May 8 11:29:12 EDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This fixes display of tracebacks in the logs, and adds logger names
- ---
 sugar/logger.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/sugar/logger.py b/sugar/logger.py
index 5cd3d72..d6b6d43 100644
- --- a/sugar/logger.py
+++ b/sugar/logger.py
@@ -29,6 +29,8 @@ _log_writer = None
 STDOUT_LEVEL = 1000
 STDERR_LEVEL = 2000
 
+formatter = logging.Formatter('%(name)s: %(message)s')
+
 class LogWriter:
     def __init__(self, module_id):
         self._module_id = module_id
@@ -38,7 +40,7 @@ class LogWriter:
         self._log_file = open(log_path, 'w')
 
     def write_record(self, record):
- -        self.write(record.levelno, record.getMessage())
+        self.write(record.levelno, formatter.format(record))
 
     def write(self, level, msg):
         if level == logging.ERROR:
- -- 
1.5.1.3

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: OpenPGP key: http://www.pseudorandom.co.uk/2003/contact/ or pgp.net

iD8DBQFGQJdIWSc8zVUw7HYRAj+JAJoDJA6nA7Ne5Q0WlxH5cQite0um0QCfSSkQ
qgCbFCC+J9Tz4I4TBdS13Sw=
=kPro
-----END PGP SIGNATURE-----


More information about the Sugar mailing list