summaryrefslogtreecommitdiff
path: root/ami.py
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-11-11 22:07:55 -0800
committerFuwn <[email protected]>2024-11-11 22:07:55 -0800
commitcc1ef8f2d61bb3e10a7e9b1c4ba38ac60a98acf7 (patch)
tree95825e3f974c5531beaa9cf906787c841646868f /ami.py
parentfeat: enhance location definitions (diff)
downloadami-cc1ef8f2d61bb3e10a7e9b1c4ba38ac60a98acf7.tar.xz
ami-cc1ef8f2d61bb3e10a7e9b1c4ba38ac60a98acf7.zip
feat: optional logging
Diffstat (limited to 'ami.py')
-rw-r--r--ami.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/ami.py b/ami.py
index 21062b5..3d510dd 100644
--- a/ami.py
+++ b/ami.py
@@ -23,9 +23,12 @@ target_cities = environ.get("TARGET_CITIES") or ""
def log_response(data):
- with open("jobs.json", "a") as log_file:
- json.dump({"timestamp": datetime.now().isoformat(), "data": data}, log_file)
- log_file.write("\n")
+ log = environ.get("LOG")
+
+ if log is not None:
+ with open(log, "a") as log_file:
+ json.dump({"timestamp": datetime.now().isoformat(), "data": data}, log_file)
+ log_file.write("\n")
def notify(title, body, job_id=None):