Skip to content

Commit 72008a7

Browse files
committed
Improve logging output and add mode indicator
Refines log messages for success and failure with clearer symbols and colors. Adds a mode indicator at startup to clarify whether the script is generating diffs, building development variants, or building production variants.
1 parent 5f78a64 commit 72008a7

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/style_variant_builder/build.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class ColourFormatter(logging.Formatter):
2929
"ERROR": "\033[1;31m", # Bright Red
3030
}
3131
RESET = "\033[0m"
32+
GREEN = "\033[32m" # Green for success
3233

3334
def format(self, record: logging.LogRecord) -> str:
3435
colour = self.COLOURS.get(record.levelname, "")
@@ -106,13 +107,13 @@ def _generate_single_diff(
106107
return (
107108
dev_file.name,
108109
True,
109-
f"No differences found for {dev_file.name}.",
110+
f"{dev_file.stem}",
110111
)
111112

112113
diff_path = diffs_dir / dev_file.with_suffix(".diff").name
113114
diffs_dir.mkdir(parents=True, exist_ok=True)
114115
diff_path.write_text("".join(diff), encoding="utf-8")
115-
return (dev_file.name, True, f"Generated diff file: {diff_path}")
116+
return (dev_file.name, True, f" {diff_path.name}")
116117

117118
except Exception as e:
118119
return (dev_file.name, False, f"Error generating diff: {e}")
@@ -170,7 +171,7 @@ def _process_single_diff(
170171
return (
171172
diff_path.name,
172173
True,
173-
f"Exported development variant to {dev_variant}",
174+
f"{dev_variant.stem}",
174175
)
175176
else:
176177
output_variant = (
@@ -188,7 +189,7 @@ def _process_single_diff(
188189
return (
189190
diff_path.name,
190191
True,
191-
f"Generated variant: {output_variant}",
192+
f"{output_variant.stem}",
192193
)
193194

194195
except Exception as e:
@@ -276,7 +277,7 @@ def build_variants(self) -> tuple[int, int]:
276277
logging.info(message)
277278
self.successful_variants += 1
278279
else:
279-
logging.error(f"Failed {diff_name}: {message}")
280+
logging.error(f" {diff_name}: {message}")
280281
self.failed_variants += 1
281282

282283
return (self.successful_variants, self.failed_variants)
@@ -341,7 +342,7 @@ def generate_diff_files(self) -> None:
341342
if success:
342343
logging.info(message)
343344
else:
344-
logging.error(f"Failed {filename}: {message}")
345+
logging.error(f" {filename}: {message}")
345346

346347

347348
def main() -> int:
@@ -415,6 +416,16 @@ def main() -> int:
415416
for template in template_files
416417
]
417418

419+
# Print mode indicator
420+
if args.diffs:
421+
logging.info("Mode: \033[1;35mGenerating diff files\033[0m\n")
422+
elif args.development:
423+
logging.info(
424+
"Mode: \033[1;35mBuilding development variants (unpruned)\033[0m\n"
425+
)
426+
else:
427+
logging.info("Mode: \033[1;35mBuilding production variants\033[0m\n")
428+
418429
overall_success = True
419430
family_results = {} # Track results per family
420431

0 commit comments

Comments
 (0)