Replace all console statements with centralized logger for consistent logging across components and stores.

This commit is contained in:
Jan 2025-12-05 18:11:34 +01:00
parent 0fef090372
commit 2fcba02227
8 changed files with 15 additions and 16 deletions

View file

@ -76,6 +76,7 @@ import Spinner from "@/components/UI/Spinner.vue";
import Flag from "@/components/UI/Flag.vue";
import {useDebounceFn} from "@vueuse/core";
import BasicBadge from "@/components/UI/BasicBadge.vue";
import logger from "@/logger.js";
export default {
name: 'AutosuggestSearchbar',
@ -182,7 +183,7 @@ export default {
this.highlightedIndex = -1
this.$emit('suggestions-loaded', this.suggestions)
} catch (error) {
console.error('Error fetching suggestions:', error)
logger.error('Error fetching suggestions:', error)
this.suggestions = []
this.hideSuggestions()
this.$emit('error', error)

View file

@ -144,8 +144,6 @@ export default {
},
handleClickOutside(event) {
console.log("HANDLE click outside")
if (!this.$refs.dropdown?.contains(event.target)) {
this.closeDropdown()
}

View file

@ -45,6 +45,7 @@ import {usePremiseEditStore} from "@/store/premiseEdit.js";
import {toRaw} from "vue";
import DestinationMassRouteRow from "@/components/layout/edit/destination/mass/DestinationMassRouteRow.vue";
import Flag from "@/components/UI/Flag.vue";
import logger from "@/logger.js";
export default {
name: "DestinationMassRoute",
@ -234,7 +235,7 @@ export default {
existingDest.disabled = false;
if(existingDest.ids.includes(curDestOfPremise.id))
console.log("Duplicate id: ", curDestOfPremise.id);
logger.log("Duplicate id: ", curDestOfPremise.id);
existingDest.ids.push(curDestOfPremise.id);
@ -248,7 +249,7 @@ export default {
const premiseRoutes = premiseDest.routes;
if (rowDest.routes.length !== premiseRoutes.length) {
console.log("length mismatch ", toRaw(rowDest), toRaw(premiseDest));
logger.log("length mismatch ", toRaw(rowDest), toRaw(premiseDest));
rowDest.valid = false;
return
}
@ -259,7 +260,7 @@ export default {
const rowRoute = rowDest.routes.find(r => r.routeCompareString === routeString && r.type === route.type);
if (!rowRoute) {
console.log("no matching route ", routeString, rowDest);
logger.log("no matching route ", routeString, rowDest);
rowDest.valid = false;
} else {
rowRoute.ids.push(route.id);

View file

@ -1,7 +1,7 @@
import log from 'loglevel'
if (process.env.NODE_ENV === 'production') {
log.setLevel('debug') //TODO change back to 'silent'
log.setLevel('silent')
} else {
log.setLevel('debug')
}

View file

@ -172,6 +172,7 @@ import DestinationMassEdit from "@/components/layout/edit/destination/mass/Desti
import DestMassCreate from "@/components/layout/edit/destination/mass/DestMassCreate.vue";
import ModalDialog from "@/components/UI/ModalDialog.vue";
import destinationEdit from "@/components/layout/edit/destination/DestinationEdit.vue";
import logger from "@/logger.js";
const COMPONENT_TYPES = {
@ -410,7 +411,7 @@ export default {
openModal(type, ids, dataSource = -1, massEdit = true) {
console.log("open modal", type, ids, dataSource, massEdit, this.modalStash, this.modalDialogShow)
logger.log("open modal", type, ids, dataSource, massEdit, this.modalStash, this.modalDialogShow)
if ((type === 'amount' || type === 'routes') && this.modalStash === null) {
@ -430,7 +431,7 @@ export default {
}
if (!this.modalDialogShow) {
console.log("open modal (actual)", type, ids, dataSource, massEdit, this.modalStash, this.modalDialogShow)
logger.log("open modal (actual)", type, ids, dataSource, massEdit, this.modalStash, this.modalDialogShow)
this.fillData(type, dataSource, massEdit);
this.editIds = ids;
this.modalType = type;

View file

@ -95,8 +95,8 @@ export const useNotificationStore = defineStore('notification', {
this.stopAutoSubmitTimer()
this.sendCache = [];
} else {
console.error("Error transmitting errors: " + url, params);
console.error(response, await response?.text());
logger.error("Error transmitting errors: " + url, params);
logger.error(response, await response?.text());
this.startAutoSubmitTimer();
}
},
@ -137,7 +137,7 @@ export const useNotificationStore = defineStore('notification', {
}
}
} catch (err) {
console.warn('Failed to capture store state:', err);
logger.warn('Failed to capture store state:', err);
return {};
}

View file

@ -219,8 +219,6 @@ export const usePremiseEditStore = defineStore('premiseEdit', {
},
async batchUpdatePrice(ids, priceData) {
console.log("batchUpdatePrice", ids, priceData)
const updatedPremises = this.premisses.map(p => {
if (ids.includes(p.id)) {
return {
@ -284,7 +282,7 @@ export const usePremiseEditStore = defineStore('premiseEdit', {
let success = true;
const toBeUpdated = this.premisses ? (ids ? (ids.map(id => this.premisses.find(p => String(p.id) === String(id)))) : (this.selectedIds.map(id => this.premisses.find(p => String(p.id) === String(id))))) : null;
console.log("toBeUpdated", ids, toBeUpdated, priceData);
if (!toBeUpdated?.length) return;