fix logging
This commit is contained in:
@@ -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 polib import pofile
|
||||
|
||||
from logger import get_logger
|
||||
from config import BASE_DIR, LOCALE_DIR, CONFIGURATION
|
||||
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.
|
||||
SOURCE_WARN = 'This English source file is machine-generated. Do not check it into github'
|
||||
|
||||
def main ():
|
||||
log = get_logger(__name__)
|
||||
log = logging.getLogger(__name__)
|
||||
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
|
||||
create_dir_if_necessary(LOCALE_DIR)
|
||||
source_msgs_dir = CONFIGURATION.source_messages_dir
|
||||
|
||||
|
||||
@@ -13,10 +13,9 @@
|
||||
languages to generate.
|
||||
"""
|
||||
|
||||
import os
|
||||
import os, sys, logging
|
||||
from polib import pofile
|
||||
|
||||
from logger import get_logger
|
||||
from config import BASE_DIR, CONFIGURATION
|
||||
from execute import execute, remove_file
|
||||
|
||||
@@ -72,7 +71,8 @@ def validate_files(dir, files_to_merge):
|
||||
raise Exception("I18N: Cannot generate because file not found: {0}".format(pathname))
|
||||
|
||||
def main ():
|
||||
log = get_logger(__name__)
|
||||
log = logging.getLogger(__name__)
|
||||
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
|
||||
|
||||
for locale in CONFIGURATION.locales:
|
||||
merge(locale)
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
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
|
||||
@@ -1,8 +1,7 @@
|
||||
import os
|
||||
import os, sys, logging
|
||||
from unittest import TestCase
|
||||
from nose.plugins.skip import SkipTest
|
||||
|
||||
from logger import get_logger
|
||||
from config import LOCALE_DIR
|
||||
from execute import call
|
||||
|
||||
@@ -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.
|
||||
"""
|
||||
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 name in filenames:
|
||||
print name
|
||||
(base, ext) = os.path.splitext(name)
|
||||
if ext.lower() == '.po':
|
||||
yield validate_po_file, os.path.join(dirpath, name), log
|
||||
|
||||
Reference in New Issue
Block a user