Mercurial > hg > sworduploader
annotate sword2-libraries-pyinstaller-compatible/sword2/sword2_logging.py @ 22:d1752c7031e4 timeouts tip
Updated .hgignore to ignore sword2_logging.conf and anything in .cache
author | Steve Welburn <stephen.welburn@eecs.qmul.ac.uk> |
---|---|
date | Tue, 22 Jan 2013 14:43:42 +0000 |
parents | 8b69bba225c9 |
children |
rev | line source |
---|---|
marco@16 | 1 #!/usr/bin/env python |
marco@16 | 2 # -*- coding: utf-8 -*- |
marco@16 | 3 |
marco@16 | 4 """ |
marco@16 | 5 `sword2` logging |
marco@16 | 6 """ |
marco@16 | 7 |
marco@16 | 8 import logging |
marco@16 | 9 import logging.config |
marco@16 | 10 from os import path as os_path |
marco@16 | 11 |
marco@16 | 12 SWORD2_LOGGING_CONFIG = "./sword2_logging.conf" # default |
marco@16 | 13 |
marco@16 | 14 BASIC_CONFIG = """[loggers] |
marco@16 | 15 keys=root |
marco@16 | 16 |
marco@16 | 17 [handlers] |
marco@16 | 18 keys=consoleHandler |
marco@16 | 19 |
marco@16 | 20 [formatters] |
marco@16 | 21 keys=basicFormatting |
marco@16 | 22 |
marco@16 | 23 [logger_root] |
marco@16 | 24 level=INFO |
marco@16 | 25 handlers=consoleHandler |
marco@16 | 26 |
marco@16 | 27 [handler_consoleHandler] |
marco@16 | 28 class=StreamHandler |
marco@16 | 29 level=DEBUG |
marco@16 | 30 formatter=basicFormatting |
marco@16 | 31 args=(sys.stdout,) |
marco@16 | 32 |
marco@16 | 33 [formatter_basicFormatting] |
marco@16 | 34 format=%(asctime)s - %(name)s - %(levelname)s - %(message)s |
marco@16 | 35 """ |
marco@16 | 36 |
marco@16 | 37 def create_logging_config(pathtologgingconf): |
marco@16 | 38 fn = open(pathtologgingconf, "w") |
marco@16 | 39 fn.write(BASIC_CONFIG) |
marco@16 | 40 fn.close() |
marco@16 | 41 |
marco@16 | 42 if not os_path.isfile(SWORD2_LOGGING_CONFIG): |
marco@16 | 43 create_logging_config(SWORD2_LOGGING_CONFIG) |
marco@16 | 44 |
marco@16 | 45 logging.config.fileConfig(SWORD2_LOGGING_CONFIG) |
marco@16 | 46 |