# Path: torext/log.py
# def set_logger(name,
#                level='INFO',
#                fmt=None,
#                datefmt=None,
#                propagate=1,
#                remove_handlers=False):
#     """
#     This function will clear the previous handlers and set only one handler,
#     which will only be StreamHandler for the logger.
# 
#     This function is designed to be able to called multiple times in a context.
# 
#     Note that if a logger has no handlers, it will be added a handler automatically when it is used.
#     """
#     logger = logging.getLogger(name)
#     logger.setLevel(getattr(logging, level))
#     logger.propagate = propagate
# 
#     if remove_handlers:
#         logger.handlers = []
#         return
# 
#     handler = None
#     for h in logger.handlers:
#         if isinstance(h, logging.StreamHandler):
#             # use existing instead of clean and create
#             handler = h
#             break
#     if not handler:
#         handler = logging.StreamHandler()
#         logger.addHandler(handler)
# 
#     formatter_kwgs = {}
#     for i in ('fmt', 'datefmt'):
#         if locals()[i] is not None:
#             formatter_kwgs[i] = locals()[i]
#     handler.setFormatter(BaseFormatter(**formatter_kwgs))
# 
# Path: torext/compat.py
# PY2 = sys.version_info.major == 2


import logging
from torext.log import set_logger
from nose.tools import with_setup
from torext.compat import PY2
#!/usr/bin/env python
# -*- coding: utf-8 -*-



def test_logging():
    msgs = [
        '中文 utf8',
        '始める utf8',
    ]
    if PY2:
        msgs += [
            u'中文 gbk'.encode('gbk'),
            u'中文 unicode',
            u'始める shift_jis'.encode('shift_jis'),
            u'始める unicode',
        ]

# Path: torext/log.py
# def set_logger(name,
#                level='INFO',
#                fmt=None,
#                datefmt=None,
#                propagate=1,
#                remove_handlers=False):
#     """
#     This function will clear the previous handlers and set only one handler,
#     which will only be StreamHandler for the logger.
# 
#     This function is designed to be able to called multiple times in a context.
# 
#     Note that if a logger has no handlers, it will be added a handler automatically when it is used.
#     """
#     logger = logging.getLogger(name)
#     logger.setLevel(getattr(logging, level))
#     logger.propagate = propagate
# 
#     if remove_handlers:
#         logger.handlers = []
#         return
# 
#     handler = None
#     for h in logger.handlers:
#         if isinstance(h, logging.StreamHandler):
#             # use existing instead of clean and create
#             handler = h
#             break
#     if not handler:
#         handler = logging.StreamHandler()
#         logger.addHandler(handler)
# 
#     formatter_kwgs = {}
#     for i in ('fmt', 'datefmt'):
#         if locals()[i] is not None:
#             formatter_kwgs[i] = locals()[i]
#     handler.setFormatter(BaseFormatter(**formatter_kwgs))
# 
# Path: torext/compat.py
# PY2 = sys.version_info.major == 2


# Path: torext/test/log_test.py
import logging
from torext.log import set_logger
from nose.tools import with_setup
from torext.compat import PY2

#!/usr/bin/env python
# -*- coding: utf-8 -*-



def test_logging():
    msgs = [
        '中文 utf8',
        '始める utf8',
    ]
    if PY2:
        msgs += [
            u'中文 gbk'.encode('gbk'),
            u'中文 unicode',
            u'始める shift_jis'.encode('shift_jis'),
            u'始める unicode',
        ]

    for i in msgs: