<commit_before>#!/usr/bin/python
import tornado.ioloop, tornado.web, tornado.options
import sys, os, yaml
import controller.base
import logging
from logging import *

# Log config. Try to use ./exp.py -log=DEBUG
loglevel='INFO'
numeric_level = getattr(logging, loglevel.upper(), None)
if not isinstance(numeric_level, int):
    raise ValueError('Invalid log level: %s' % loglevel)
logging.basicConfig(level=numeric_level, format='[%(asctime)s][%(levelname)s] %(message)s')

def __ReadConfigFile__():
    config_filename="config.yaml"
    conf={}
    try:
        with open(config_filename,'r') as fin:
            conf = yaml.load(fin)
    except:
        print("Has no or invaild config file. Use default value")
    conf   

# run config
setting = {
    "debug":True,
    "default_handler_class": "controller.error.Error403",
    "static_path": "static",
}
__ReadConfigFile__()

#sys config
tornado.options.define("port", default=80, help="listening port", type=int)
tornado.options.define("addr", default="127.0.0.1", help="listening address")
tornado.options.parse_command_line()

application = tornado.web.Application([
    (r"^/$", "controller.page.IndexPage"),
    (r"^/article.aspx/([\w-!():.,\[\]]+)$", "controller.article.ArticleHandler"),
    (r"^/list.aspx/*$", "controller.list.FirstPageHandler"),
    (r"^/list.aspx/(\d+)$", "controller.list.PageHandler"),
    (r"^/page.aspx/([\w-!():.,\[\]]+)$", "controller.page.SpecialPageHandler")
], **setting)




if __name__ == "__main__":
    try:
        application.listen(80)
        tornado.ioloop.IOLoop.instance().start()
    except:
        import traceback
        print(traceback.print_exc())
    finally:
        sys.exit(0)<commit_msg>Modified all `print` to logging.{fun}<commit_after>#!/usr/bin/python
import tornado.ioloop, tornado.web, tornado.options
import sys, os, yaml
import controller.base
import logging
from logging import *

# Log config. Try to use ./exp.py -log=DEBUG
loglevel='INFO'
numeric_level = getattr(logging, loglevel.upper(), None)
if not isinstance(numeric_level, int):
    raise ValueError('Invalid log level: %s' % loglevel)
logging.basicConfig(level=numeric_level, format='[%(asctime)s][%(levelname)s] %(message)s')

def __ReadConfigFile__():
    config_filename="config.yaml"
    conf={}
    try:
        with open(config_filename,'r') as fin:
            conf = yaml.load(fin)
    except:
        warning("Has no or invaild config file. Use default value")
    conf   

# run config
setting = {
    "debug":True,
    "default_handler_class": "controller.error.Error403",
    "static_path": "static",
}
__ReadConfigFile__()

#sys config
tornado.options.define("port", default=80, help="listening port", type=int)
tornado.options.define("addr", default="127.0.0.1", help="listening address")
tornado.options.parse_command_line()

application = tornado.web.Application([
    (r"^/$", "controller.page.IndexPage"),
    (r"^/article.aspx/([\w-!():.,\[\]]+)$", "controller.article.ArticleHandler"),
    (r"^/list.aspx/*$", "controller.list.FirstPageHandler"),
    (r"^/list.aspx/(\d+)$", "controller.list.PageHandler"),
    (r"^/page.aspx/([\w-!():.,\[\]]+)$", "controller.page.SpecialPageHandler")
], **setting)




if __name__ == "__main__":
    try:
        application.listen(80)
        tornado.ioloop.IOLoop.instance().start()
    except:
        import traceback
        error(traceback.print_exc())
    finally:
        sys.exit(0)
{'fraction_non_alphanumeric': 0.17755102040816326, 'fraction_numerical': 0.00816326530612245, 'mean_word_length': 4.016081871345029, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4498292', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1124, 'n_words': 221}