added method in utils for configuring loggging in file
MODIFY
rasa_sdk/utils.py
rasa_sdk/utils.py
@@ -85,6 +85,25 @@ def configure_colored_logging(loglevel):
)
+def configure_file_logging(
+ logger_obj: logging.Logger, log_file: Optional[Text]
+) -> None:
+ """Configure logging to a file.
+
+ Args:
+ logger_obj: Logger object to configure.
+ log_file: Path of log file to write to.
+ """
+ if not log_file:
+ return
+
+ formatter = logging.Formatter("%(asctime)s [%(levelname)-5.5s] %(message)s")
+ file_handler = logging.FileHandler(log_file, encoding="utf-8")
+ file_handler.setLevel(logger_obj.level)
+ file_handler.setFormatter(formatter)
+ logger_obj.addHandler(file_handler)
+
+
def arguments_of(func) -> AbstractSet[Text]:
"""Return the parameters of the function `func` as a list of their names."""

added method in utils for configuring loggging in file