Default output to logs/YYYY_MM_DD_HH_MM_SS_<VIN>.log

When -o is omitted, the output file is auto-named from the run's
start timestamp and the vehicle VIN and placed under ./logs/,
which is created on demand.  logs/ is gitignored.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 19:07:31 +02:00
co-authored by Claude Sonnet 4.6
parent dcd5910b3d
commit 725b480cb4
2 changed files with 16 additions and 6 deletions
+2 -1
View File
@@ -1,3 +1,4 @@
.idea/
credentials/
vehicle_data.json
vehicle_data.json
logs/
+14 -5
View File
@@ -12,7 +12,10 @@ Usage examples
export WC_USER=me@example.com WC_PASS=secret
python collect.py
# Credentials from a JSON file:
# Credentials from a JSON file (output auto-named under ./logs/):
python collect.py -c creds.json -i 600
# Credentials from a JSON file, explicit output path:
python collect.py -c creds.json -i 600 -o id3.json
# Custom domains, 10-minute interval:
@@ -378,8 +381,6 @@ def run(args: argparse.Namespace) -> None:
log.error("Unknown domain(s): %s. Available: %s", unknown, list(ALL_DOMAINS))
sys.exit(1)
out = Path(args.output)
log.info("Connecting to WeConnect…")
wc = weconnect.WeConnect(
username=args.username,
@@ -410,6 +411,14 @@ def run(args: argparse.Namespace) -> None:
vin = vehicle.vin.value
log.info("Vehicle: %s", vin)
if args.output:
out = Path(args.output)
else:
logs_dir = Path("logs")
logs_dir.mkdir(exist_ok=True)
stamp = datetime.now().strftime("%Y_%m_%d_%H_%M_%S")
out = logs_dir / f"{stamp}_{vin}.log"
store = load_store(out, vin, args.interval)
log.info(
"Collecting [%s] every %ds → %s (Ctrl-C to stop)",
@@ -487,9 +496,9 @@ def main() -> None:
)
p.add_argument(
"-o", "--output",
default="vehicle_data.json",
default=None,
metavar="FILE",
help="Output JSON file (default: vehicle_data.json)",
help="Output file (default: logs/YYYY_MM_DD_HH_MM_SS_<VIN>.log)",
)
p.add_argument(
"--max-records",