Commits

Vinay Sajip committed e338cb3

Changes for 0.3.3.

Comments (0)

Files changed (21)

-Copyright (c) 2008-2011 by Vinay Sajip.
+Copyright (c) 2008-2013 by Vinay Sajip.
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 What's New in logutils
 ======================
 
+Version 0.3.3
+-------------
+
+- Added encoding support to ColorizingStreamHandler.
+
 Version 0.3.2
 -------------
 
-logutils 0.1
-============
+logutils 0.3.3
+==============
 The logutils package provides a set of handlers for the Python standard
 library's logging package.
 
 
 # General information about the project.
 project = u'Logutils'
-copyright = u'2010-2011, Vinay Sajip'
+copyright = u'2010-2013, Vinay Sajip'
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
 # The short X.Y version.
 version = '0.3'
 # The full version, including alpha/beta/rc tags.
-release = '0.3.2'
+release = '0.3.3'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.

logutils/__init__.py

+#
+# Copyright (C) 2010-2013 Vinay Sajip. See LICENSE.txt for details.
+#
 """
 The logutils package provides a set of handlers for the Python standard
 library's logging package.
 import logging
 from string import Template
 
-__version__ = '0.3.2'
+__version__ = '0.3.3'
 
 class NullHandler(logging.Handler):
     """

logutils/adapter.py

-# Copyright (C) 2010 Vinay Sajip. All Rights Reserved.
 #
-# Permission to use, copy, modify, and distribute this software and its
-# documentation for any purpose and without fee is hereby granted,
-# provided that the above copyright notice appear in all copies and that
-# both that copyright notice and this permission notice appear in
-# supporting documentation, and that the name of Vinay Sajip
-# not be used in advertising or publicity pertaining to distribution
-# of the software without specific, written prior permission.
-# VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
-# VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
-# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
-# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+# Copyright (C) 2010-2013 Vinay Sajip. See LICENSE.txt for details.
 #
-
 import logging
 import logutils
 

logutils/colorize.py

 #
-# Copyright (C) 2010-2011 Vinay Sajip. All rights reserved.
+# Copyright (C) 2010-2013 Vinay Sajip. All rights reserved.
 #
 import ctypes
 import logging
 import os
 
+try:
+    unicode
+except NameError:
+    unicode = None
+
 class ColorizingStreamHandler(logging.StreamHandler):
     """
     A stream handler which supports colorizing of console streams
         try:
             message = self.format(record)
             stream = self.stream
+            if unicode and isinstance(message, unicode):
+                enc = getattr(stream, 'encoding', 'utf-8')
+                message = message.encode(enc, 'replace')
             if not self.is_tty:
                 stream.write(message)
             else:

logutils/dictconfig.py

-# Copyright 2009-2010 by Vinay Sajip. All Rights Reserved.
 #
-# Permission to use, copy, modify, and distribute this software and its
-# documentation for any purpose and without fee is hereby granted,
-# provided that the above copyright notice appear in all copies and that
-# both that copyright notice and this permission notice appear in
-# supporting documentation, and that the name of Vinay Sajip
-# not be used in advertising or publicity pertaining to distribution
-# of the software without specific, written prior permission.
-# VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
-# VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
-# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
-# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+# Copyright (C) 2009-2013 Vinay Sajip. See LICENSE.txt for details.
+#
 import logging.handlers
 import re
 import sys
+#
+# Copyright (C) 2010-2013 Vinay Sajip. See LICENSE.txt for details.
+#
 import logging
 
 class HTTPHandler(logging.Handler):

logutils/queue.py

-# Copyright (C) 2010 Vinay Sajip. All Rights Reserved.
 #
-# Permission to use, copy, modify, and distribute this software and its
-# documentation for any purpose and without fee is hereby granted,
-# provided that the above copyright notice appear in all copies and that
-# both that copyright notice and this permission notice appear in
-# supporting documentation, and that the name of Vinay Sajip
-# not be used in advertising or publicity pertaining to distribution
-# of the software without specific, written prior permission.
-# VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
-# VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
-# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
-# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+# Copyright (C) 2010-2013 Vinay Sajip. See LICENSE.txt for details.
 #
 """
 This module contains classes which help you work with queues. A typical

logutils/redis.py

+#
+# Copyright (C) 2011-2013 Vinay Sajip. See LICENSE.txt for details.
+#
 """
 This module contains classes which help you work with Redis queues.
 """

logutils/testing.py

-# Copyright (C) 2010 Vinay Sajip. All Rights Reserved.
 #
-# Permission to use, copy, modify, and distribute this software and its
-# documentation for any purpose and without fee is hereby granted,
-# provided that the above copyright notice appear in all copies and that
-# both that copyright notice and this permission notice appear in
-# supporting documentation, and that the name of Vinay Sajip
-# not be used in advertising or publicity pertaining to distribution
-# of the software without specific, written prior permission.
-# VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
-# VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
-# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
-# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+# Copyright (C) 2010-2013 Vinay Sajip. See LICENSE.txt for details.
 #
 import logging
 from logging.handlers import BufferingHandler
     url='http://code.google.com/p/logutils/',
     description='Logging utilities',
     long_description = description(),
-    license='Copyright (C) 2010-2011 by Vinay Sajip. All Rights Reserved. See LICENSE.txt for license.',
+    license='Copyright (C) 2010-2013 by Vinay Sajip. All Rights Reserved. See LICENSE.txt for license.',
     classifiers=[
         'Development Status :: 5 - Production/Stable',
         'Environment :: Console',
         'License :: OSI Approved :: BSD License',
         'Operating System :: OS Independent',
         'Programming Language :: Python',
+        "Programming Language :: Python :: 2",
         "Programming Language :: Python :: 3",
         'Topic :: Software Development',
     ],

tests/logutil_tests.py

+#
+# Copyright (C) 2008-2013 Vinay Sajip. See LICENSE.txt for details.
+#
 import sys
 from test_testing import LoggingTest
 from test_dictconfig import ConfigDictTest
 from test_queue import QueueTest
 from test_formatter import FormatterTest
 from test_messages import MessageTest
+from test_colorize import ColorizeTest
 try:
     from test_redis import RedisQueueTest
 except ImportError:

tests/test_adapter.py

+#
+# Copyright (C) 2008-2013 Vinay Sajip. See LICENSE.txt for details.
+#
 import logging
 from logutils.adapter import LoggerAdapter
 from logutils.testing import TestHandler, Matcher

tests/test_colorize.py

+#
+# Copyright (C) 2012-2013 Vinay Sajip. See LICENSE.txt for details.
+#
+import logging
+import logutils.colorize
+import os
+import sys
+import unittest
+
+if sys.version_info[0] < 3:
+    u = lambda o: unicode(o, 'unicode_escape')
+else:
+    u = lambda o: o
+
+class ColorizeTest(unittest.TestCase):
+
+    def test_colorize(self):
+        logger = logging.getLogger()
+        handler = logutils.colorize.ColorizingStreamHandler()
+        logger.addHandler(handler)
+        try:
+            logger.warning(u('Some unicode string with some \u015b\u0107\u017a\xf3\u0142 chars'))
+        finally:
+            logger.removeHandler(handler)
+

tests/test_dictconfig.py

-# Copyright 2009-2010 by Vinay Sajip. All Rights Reserved.
 #
-# Permission to use, copy, modify, and distribute this software and its
-# documentation for any purpose and without fee is hereby granted,
-# provided that the above copyright notice appear in all copies and that
-# both that copyright notice and this permission notice appear in
-# supporting documentation, and that the name of Vinay Sajip
-# not be used in advertising or publicity pertaining to distribution
-# of the software without specific, written prior permission.
-# VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
-# VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
-# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
-# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+# Copyright 2009-2013 by Vinay Sajip. See LICENSE.txt for details.
+#
 import logging
 from logutils.adapter import LoggerAdapter
 from logutils.dictconfig import dictConfig, named_handlers_supported

tests/test_formatter.py

+#
+# Copyright (C) 2009-2013 Vinay Sajip. See LICENSE.txt for details.
+#
 import logging
 import logutils
 import os

tests/test_queue.py

+#
+# Copyright (C) 2010-2013 Vinay Sajip. See LICENSE.txt for details.
+#
 import logging
 from logutils.testing import TestHandler, Matcher
 from logutils.queue import QueueHandler, QueueListener, queue

tests/test_redis.py

+#
+# Copyright (C) 2011-2013 Vinay Sajip. See LICENSE.txt for details.
+#
 import logging
 from logutils.testing import TestHandler, Matcher
 from logutils.redis import RedisQueueHandler, RedisQueueListener

tests/test_testing.py

+#
+# Copyright (C) 2010-2013 Vinay Sajip. See LICENSE.txt for details.
+#
 import logging
 from logutils.testing import TestHandler, Matcher
 import unittest