Files
0ad/source/tools/i18n/txclib/log.py
T
Gallaecio 64d204228a Message extraction and localization
It includes the translation template files (POT) as well as translation
files
(PO) developer through the Transifex platform by our awesome
translators.

It also includes tools to generate the translation template files,
generate a
special translation file with the longest strigns of all translations,
and a
tool to download translations from Transifex into the right game folders
automatically.

Fixes #67

This was SVN commit r14955.
2014-04-20 21:48:23 +00:00

38 lines
880 B
Python

# -*- coding: utf-8 -*-
"""
Add logging capabilities to tx-client.
"""
import sys
import logging
_logger = logging.getLogger('txclib')
_logger.setLevel(logging.INFO)
_formatter = logging.Formatter('%(message)s')
_error_handler = logging.StreamHandler(sys.stderr)
_error_handler.setLevel(logging.ERROR)
_error_handler.setFormatter(_formatter)
_logger.addHandler(_error_handler)
_msg_handler = logging.StreamHandler(sys.stdout)
_msg_handler.setLevel(logging.DEBUG)
_msg_handler.setFormatter(_formatter)
_msg_filter = logging.Filter()
_msg_filter.filter = lambda r: r.levelno < logging.ERROR
_msg_handler.addFilter(_msg_filter)
_logger.addHandler(_msg_handler)
logger = _logger
def set_log_level(level):
"""Set the level for the logger.
Args:
level: A string among DEBUG, INFO, WARNING, ERROR, CRITICAL.
"""
logger.setLevel(getattr(logging, level))