问题
I'd like to be able to log outputs from the functions I pass to my engines in the relevant engine logs.
I.e.:
data = /* my list of data to operate on */
def fn(inval):
import logging
log = logging.getLogger()
log.error('This is on the engine')
// do stuff
return result
calculated_data = []
for datum in data:
calc = view.apply(fn, datum)
calculated_data.append(calc)
I'd like to be able to see the log statements in the relevant engine log that operated on the specific task.
回答1:
You can grab the logger of the current app (i.e. the engine in this case) with:
from IPython.config import Application
log = Application.instance().log
Then log as normal, and it will go to the engine logs.
来源:https://stackoverflow.com/questions/15146168/ipython-parallel-can-i-write-my-own-log-into-the-engine-logs