nicer logs

This commit is contained in:
iw0
2024-05-07 17:46:34 +02:00
parent 3caffd249c
commit d9c2c818f1
3 changed files with 39 additions and 27 deletions

View File

@@ -11,7 +11,7 @@ async function getAuthToken() {
tok = tokInspect;
}
} else {
console.log("No accessToken available. Sleeping...")
console.info("No accessToken available. Sleeping...")
await new Promise(res => setTimeout(res, 5000));
}
}
@@ -54,11 +54,11 @@ async function getBahncardInfo() {
});
if (req.ok) {
const data = await req.json();
console.log(data);
console.debug(data);
const orders = data.bahnCardBestellungen.filter((order) => {
return order.bahncardTyp === "BC100" && (Date.parse(order.gueltigAb) < Date.now())
});
console.log("BahnCard candidates:", orders);
console.debug("BahnCard candidates:", orders);
if (orders[0] !== undefined) {
// Orders are returned in reverse chronological order.
// TODO Ask which one if there are multiple.
@@ -66,7 +66,7 @@ async function getBahncardInfo() {
return orders[0].bcNummer || false;
}
} else {
console.log("Request failed:", req);
console.error("Request failed:", req);
return false;
}
}
@@ -74,7 +74,7 @@ browser.storage.sync.get(["acquireAll","acquireBahncard"]).then(v => {
if (v.acquireAll!=false){
Promise.all([getKundenkontoV2(), getBahncardInfo()]).then(data => {
const saveData = {...data[0], "bcnum": data[1]};
console.log("Saving", saveData);
console.info("Saving", saveData);
browser.storage.sync.set(saveData).then(()=>{
alert("Saved all available data to settings.\nPlease enter your bank details on the bottom of the settings page.");
window.close();
@@ -85,12 +85,12 @@ browser.storage.sync.get(["acquireAll","acquireBahncard"]).then(v => {
getBahncardInfo().then(v => {
if (!!v && v.length == 16) {
const saveData = { "bcnum": v, "acquireBahncard": false }
console.log("Saving", saveData);
console.info("Saving", saveData);
browser.storage.sync.set(saveData).then(() => {
alert("Saved your BahnCard number to settings.\nReload the settings page to continue.");
window.close();
});
}
}, f => console.log("Could not acquire BahnCard number.", f))
}, f => console.error("Could not acquire BahnCard number.", f))
}
})