Commit beb4b39b by Steve Strassmann

fix logging

parent dc473e6f
...@@ -15,11 +15,10 @@ See https://edx-wiki.atlassian.net/wiki/display/ENG/PO+File+workflow ...@@ -15,11 +15,10 @@ See https://edx-wiki.atlassian.net/wiki/display/ENG/PO+File+workflow
""" """
import os import os, sys, logging
from datetime import datetime from datetime import datetime
from polib import pofile from polib import pofile
from logger import get_logger
from config import BASE_DIR, LOCALE_DIR, CONFIGURATION from config import BASE_DIR, LOCALE_DIR, CONFIGURATION
from execute import execute, create_dir_if_necessary, remove_file from execute import execute, create_dir_if_necessary, remove_file
...@@ -34,7 +33,8 @@ BABEL_OUT = BASE_DIR.relpathto(CONFIGURATION.source_messages_dir.joinpath('mako. ...@@ -34,7 +33,8 @@ BABEL_OUT = BASE_DIR.relpathto(CONFIGURATION.source_messages_dir.joinpath('mako.
SOURCE_WARN = 'This English source file is machine-generated. Do not check it into github' SOURCE_WARN = 'This English source file is machine-generated. Do not check it into github'
def main (): def main ():
log = get_logger(__name__) log = logging.getLogger(__name__)
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
create_dir_if_necessary(LOCALE_DIR) create_dir_if_necessary(LOCALE_DIR)
source_msgs_dir = CONFIGURATION.source_messages_dir source_msgs_dir = CONFIGURATION.source_messages_dir
......
...@@ -13,10 +13,9 @@ ...@@ -13,10 +13,9 @@
languages to generate. languages to generate.
""" """
import os import os, sys, logging
from polib import pofile from polib import pofile
from logger import get_logger
from config import BASE_DIR, CONFIGURATION from config import BASE_DIR, CONFIGURATION
from execute import execute, remove_file from execute import execute, remove_file
...@@ -72,7 +71,8 @@ def validate_files(dir, files_to_merge): ...@@ -72,7 +71,8 @@ def validate_files(dir, files_to_merge):
raise Exception("I18N: Cannot generate because file not found: {0}".format(pathname)) raise Exception("I18N: Cannot generate because file not found: {0}".format(pathname))
def main (): def main ():
log = get_logger(__name__) log = logging.getLogger(__name__)
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
for locale in CONFIGURATION.locales: for locale in CONFIGURATION.locales:
merge(locale) merge(locale)
......
import logging
def get_logger(name):
"""
Returns a default logger.
logging.basicConfig does not render to the console
"""
log = logging.getLogger()
log.setLevel(logging.INFO)
log_handler = logging.StreamHandler()
log_handler.setFormatter(logging.Formatter('%(asctime)s [%(levelname)s] %(message)s'))
log.addHandler(log_handler)
return log
import os import os, sys, logging
from unittest import TestCase from unittest import TestCase
from nose.plugins.skip import SkipTest from nose.plugins.skip import SkipTest
from logger import get_logger
from config import LOCALE_DIR from config import LOCALE_DIR
from execute import call from execute import call
...@@ -10,10 +9,11 @@ def test_po_files(root=LOCALE_DIR): ...@@ -10,10 +9,11 @@ def test_po_files(root=LOCALE_DIR):
""" """
This is a generator. It yields all of the .po files under root, and tests each one. This is a generator. It yields all of the .po files under root, and tests each one.
""" """
log = get_logger(__name__) log = logging.getLogger(__name__)
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
for (dirpath, dirnames, filenames) in os.walk(root): for (dirpath, dirnames, filenames) in os.walk(root):
for name in filenames: for name in filenames:
print name
(base, ext) = os.path.splitext(name) (base, ext) = os.path.splitext(name)
if ext.lower() == '.po': if ext.lower() == '.po':
yield validate_po_file, os.path.join(dirpath, name), log yield validate_po_file, os.path.join(dirpath, name), log
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment