<s> from __future__ import print_function <EOL> import sys <EOL> import traceback <EOL> from taskflow . listeners import base <EOL> class PrintingListener ( base . DumpingListener ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , engine , <EOL> task_listen_for = base . DEFAULT_LISTEN_FOR , <EOL> flow_listen_for = base . DEFAULT_LISTEN_FOR , <EOL> retry_listen_for = base . DEFAULT_LISTEN_FOR , <EOL> stderr = False ) : <EOL> super ( PrintingListener , self ) . __init__ ( <EOL> engine , task_listen_for = task_listen_for , <EOL> flow_listen_for = flow_listen_for , retry_listen_for = retry_listen_for ) <EOL> if stderr : <EOL> self . _file = sys . stderr <EOL> else : <EOL> self . _file = sys . stdout <EOL> def _dump ( self , message , * args , ** kwargs ) : <EOL> print ( message % args , file = self . _file ) <EOL> exc_info = kwargs . get ( '<STR_LIT>' ) <EOL> if exc_info is not None : <EOL> traceback . print_exception ( exc_info [ <NUM_LIT:0> ] , exc_info [ <NUM_LIT:1> ] , exc_info [ <NUM_LIT:2> ] , <EOL> file = self . _file ) </s>
