griptape
griptape copied to clipboard
Suppress logs for inputs and outputs on stdout
- [x] I have read and agree to the contributing guidelines.
Is your feature request related to a problem? Please describe. I dont want always see the inputs and outputs of all tasks that are running. If I am doing webscraping, for example, the entire webscraped output being printed multiple times on stdout is not useful.
Describe the solution you'd like toggle the input and output logging for tasks. we currently allow overriding of a log level or the entire logger, but its not entirely clear how I would leverage that for this case.
probably not implemented this way but this is what i am currently doing:
class BaseTask(ABC):
.....
log_input: bool = field(default=True, kw_only=True)
log_output: bool = field(default=True, kw_only=True)
and in the various Task
s that the inputs/outputs are logged:
def before_run(self) -> None:
super().before_run()
self.structure.logger.info(
f"{self.__class__.__name__} {self.id}\nInput: {self.input.to_text() if self.log_input else self.input.name}"
)
def after_run(self) -> None:
super().after_run()
self.structure.logger.info(
f"{self.__class__.__name__} {self.id}\nOutput: {self.output.to_text() if self.log_output else self.output.name}"
)
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context Add any other context or screenshots about the feature request here.