path hacking for logging.cfg

This commit is contained in:
fawce
2012-05-21 16:21:29 -04:00
parent b47a3d8241
commit 46ef2e136d
3 changed files with 13 additions and 2 deletions
+37
View File
@@ -0,0 +1,37 @@
[loggers]
keys=root
[handlers]
keys=consoleHandler,filesystemHandler
[formatters]
keys=ziplineformat
# -------
[logger_root]
level=DEBUG
handlers=consoleHandler,filesystemHandler
qualname=ZiplineLogger
# -------
[handler_filesystemHandler]
class=handlers.RotatingFileHandler
level=DEBUG
formatter=ziplineformat
args=("/var/log/zipline/zipline.log",10*1024*1024,5)
propagate=1
[handler_consoleHandler]
class=StreamHandler
level=ERROR
formatter=ziplineformat
args=(sys.stdout,)
propagate=1
# -------
[formatter_ziplineformat]
format=%(asctime)s %(levelname)s %(filename)s %(funcName)s - %(message)s
datefmt=%Y-%m-%d %H:%M:%S %Z
+6 -1
View File
@@ -1,7 +1,7 @@
"""
Factory functions to prepare useful data for tests.
"""
import os
import pytz
import msgpack
import random
@@ -21,6 +21,11 @@ def data_path():
data_path = dirname(abspath(data.__file__))
return data_path
def logger_path():
import zipline
log_path = dirname(abspath(zipline.__file__))
return os.join(log_path, 'logging.cfg')
def load_market_data():
fp_bm = open(join(data_path(), "benchmark.msgpack"), "rb")
bm_list = msgpack.loads(fp_bm.read())
+7 -1
View File
@@ -5,9 +5,15 @@ and other common operations.
import logging
import logging.config
from os.path import join, abspath, dirname
def configure_logging():
logging.config.fileConfig(
'logging.cfg',
logger_path(),
disable_existing_loggers = False
)
def logger_path():
import zipline
log_path = dirname(abspath(zipline.__file__))
return join(log_path, 'logging.cfg')