diff --git a/gentopia/output/__init__.py b/gentopia/output/__init__.py index 4ff0db1..071c19f 100755 --- a/gentopia/output/__init__.py +++ b/gentopia/output/__init__.py @@ -2,7 +2,7 @@ import os -def enable_log(path: str = "./agent.log", log_level: str= "info" ): +def enable_log(path: str = "./agent.log", log_level: str= "info", mode: str = "w" ): """ Enables logging for the application. @@ -15,7 +15,9 @@ def enable_log(path: str = "./agent.log", log_level: str= "info" ): path = "./agent.log" os.environ["LOG_LEVEL"] = log_level os.environ["LOG_PATH"] = path - logging.basicConfig(level=log_level.upper(), filename=path) + assert log_level.upper() in ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], "Invalid log level." + assert mode in ["w", "a"], "Invalid mode." + logging.basicConfig(level=log_level.upper(), filename=path, filemode=mode) @@ -25,4 +27,4 @@ def check_log(): :return: True if logging has been enabled, False otherwise. :rtype: bool """ - return os.environ.get("LOG_PATH", None) is not None \ No newline at end of file + return os.environ.get("LOG_PATH", None) is not None