Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

log mode #39

Merged
merged 1 commit into from
Jul 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions gentopia/output/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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)



Expand All @@ -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
return os.environ.get("LOG_PATH", None) is not None