Skip to content

Commit

Permalink
All log messages as JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
oh2fih committed Jul 17, 2024
1 parent 7eb6086 commit 0a69e3f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
8 changes: 5 additions & 3 deletions generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def setupDist():
try:
shutil.rmtree(dist)
except Exception as e:
print(e)
log(target="ERROR", message=f"removing {dist} failed", error=e)

os.mkdir(dist)
os.mkdir(top_sites)
Expand Down Expand Up @@ -180,8 +180,10 @@ def genStaticFiles(results: dict):
domains_dict = sites.getTop500()

if len(domains_dict) > 0:
print("Got domain lists, counts:")
print("Total -", len(domains_dict))
log(
target="INFO",
message="Got domain lists; total count {len(domains_dict)}",
)
else:
raise Exception("No domains")

Expand Down
6 changes: 5 additions & 1 deletion jinja_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import json
import subresource_integrity as integrity

from json_logger import log


def colourFromLetter(letter: str = "") -> str:
if not letter:
Expand Down Expand Up @@ -94,7 +96,9 @@ def renderTemplate(
params.update({"title": params["dest_domain"]})
else:
description = ""
print(f"Skipping canonical and description for: {filename}")
log(
target="INFO", message=f"Skipping canonical and description for: {filename}"
)

params.update({"description": description})
params.update({"canonical": canonical})
Expand Down
2 changes: 1 addition & 1 deletion sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self):
self.top500 = {}

def __str__(self) -> str:
return f"{self.getTop500()}"
return f"{json.dumps(self.getTop500())}"

def getTop500(self) -> dict:
if self.cacheAge() > Sites.CACHE_MAX_AGE:
Expand Down

0 comments on commit 0a69e3f

Please sign in to comment.