diff options
| author | Fuwn <[email protected]> | 2024-11-11 22:07:55 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-11-11 22:07:55 -0800 |
| commit | cc1ef8f2d61bb3e10a7e9b1c4ba38ac60a98acf7 (patch) | |
| tree | 95825e3f974c5531beaa9cf906787c841646868f /ami.py | |
| parent | feat: enhance location definitions (diff) | |
| download | ami-cc1ef8f2d61bb3e10a7e9b1c4ba38ac60a98acf7.tar.xz ami-cc1ef8f2d61bb3e10a7e9b1c4ba38ac60a98acf7.zip | |
feat: optional logging
Diffstat (limited to 'ami.py')
| -rw-r--r-- | ami.py | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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): |