I'd like to redirect the output of each cell of my notebook. Here is what I tried
class Logger():
def __init__(self, stdout):
self.stdout = stdout
def write(self, msg):
self.stdout.write('augmented:' + msg)
def flush(self):
self.stdout.flush()
and in a cell, I change the stdout on the fly
sys.stdout = Logger(sys.stdout)
However, the output string of the next executed cells has not the "augmented" string
