BUG: Logbook 0.10.0 requires explicit handler

As of logbook 0.10.0, logbook no longer installs a default handler,
which means that if the application doesn't install one, log messages
disappear into the ether.

Therefore, all of our scripts with `__main__` endpoints need to push a
`logbook.StderrHandler` if they're not already pushing some other
handler.
This commit is contained in:
Jonathan Kamens
2015-07-28 04:38:41 -04:00
parent 576e4184d7
commit dca679edcb
5 changed files with 10 additions and 0 deletions
@@ -14,6 +14,7 @@
# limitations under the License.
import datetime
import logbook
import os
import pickle
import pytz
@@ -136,6 +137,7 @@ def generate_object_state(cls, initargs):
if __name__ == "__main__":
logbook.StderrHandler().push_application()
for args in argument_list:
generate_object_state(*args)
+2
View File
@@ -14,11 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import logbook
import sys
from zipline.utils import parse_args, run_pipeline
if __name__ == "__main__":
logbook.StderrHandler().push_application()
parsed = parse_args(sys.argv[1:])
run_pipeline(print_algo=True, **parsed)
sys.exit(0)
+2
View File
@@ -66,12 +66,14 @@ def handle_data(context, data):
if __name__ == '__main__':
from datetime import datetime
import logbook
import matplotlib.pyplot as plt
import pytz
from zipline.algorithm import TradingAlgorithm
from zipline.api import order, record, symbol
from zipline.utils.factory import load_from_yahoo
logbook.StderrHandler().push_application()
start = datetime(2014, 1, 1, 0, 0, 0, 0, pytz.utc)
end = datetime(2014, 11, 1, 0, 0, 0, 0, pytz.utc)
data = load_from_yahoo(stocks=['AAPL'], indexes={}, start=start,
+2
View File
@@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import logbook
import matplotlib.pyplot as plt
import numpy as np
import statsmodels.api as sm
@@ -116,6 +117,7 @@ class Pairtrade(TradingAlgorithm):
self.order(self.PEP, -1 * pep_amount)
if __name__ == '__main__':
logbook.StderrHandler().push_application()
start = datetime(2000, 1, 1, 0, 0, 0, 0, pytz.utc)
end = datetime(2002, 1, 1, 0, 0, 0, 0, pytz.utc)
data = load_from_yahoo(stocks=['PEP', 'KO'], indexes={},
+2
View File
@@ -14,6 +14,7 @@
# limitations under the License.
from datetime import datetime
import logbook
import pytz
from zipline import TradingAlgorithm
@@ -34,6 +35,7 @@ def handle_date(context, data):
if __name__ == '__main__':
import pylab as pl
logbook.StderrHandler().push_application()
start = datetime(2008, 1, 1, 0, 0, 0, 0, pytz.utc)
end = datetime(2010, 1, 1, 0, 0, 0, 0, pytz.utc)
data = load_from_yahoo(stocks=['AAPL'], indexes={}, start=start,