feat(#27): Set up consola logger, make use of log levels in backend and frontend

This commit is contained in:
2025-12-24 10:26:22 +01:00
parent 805c66bc4f
commit 7f7852a66a
36 changed files with 312 additions and 141 deletions

View File

@@ -1,14 +1,16 @@
import type { ApplicationFormDto, PagedApplicationFormDto, FormElementDto } from '~~/.api-client'
import { useApplicationFormApi } from './useApplicationFormApi'
import { useLogger } from '../useLogger'
export function useApplicationForm() {
const applicationFormApi = useApplicationFormApi()
const logger = useLogger().withTag('applicationForm')
async function createApplicationForm(applicationFormDto: ApplicationFormDto): Promise<ApplicationFormDto> {
try {
return await applicationFormApi.createApplicationForm(applicationFormDto)
} catch (e: unknown) {
console.error('Failed creating application form:', e)
logger.error('Failed creating application form:', e)
return Promise.reject(e)
}
}
@@ -17,7 +19,7 @@ export function useApplicationForm() {
try {
return await applicationFormApi.getAllApplicationForms(organizationId)
} catch (e: unknown) {
console.error('Failed retrieving application forms:', e, JSON.stringify(e))
logger.error('Failed retrieving application forms:', e)
return Promise.reject(e)
}
}
@@ -26,7 +28,7 @@ export function useApplicationForm() {
try {
return await applicationFormApi.getApplicationFormById(id)
} catch (e: unknown) {
console.error(`Failed retrieving application form with ID ${id}:`, e)
logger.error(`Failed retrieving application form with ID ${id}:`, e)
return Promise.reject(e)
}
}
@@ -39,11 +41,11 @@ export function useApplicationForm() {
return Promise.reject(new Error('ID or application form DTO missing'))
}
console.log('Updating application form with ID:', id, applicationFormDto)
logger.debug('Updating application form with ID:', id, applicationFormDto)
try {
return await applicationFormApi.updateApplicationForm(id, applicationFormDto)
} catch (e: unknown) {
console.error(`Failed updating application form with ID ${id}:`, e)
logger.error(`Failed updating application form with ID ${id}:`, e)
return Promise.reject(e)
}
}
@@ -52,7 +54,7 @@ export function useApplicationForm() {
try {
return await applicationFormApi.deleteApplicationFormById(id)
} catch (e: unknown) {
console.error(`Failed deleting application form with ID ${id}:`, e)
logger.error(`Failed deleting application form with ID ${id}:`, e)
return Promise.reject(e)
}
}
@@ -65,7 +67,7 @@ export function useApplicationForm() {
try {
return await applicationFormApi.submitApplicationForm(id)
} catch (e: unknown) {
console.error(`Failed submitting application form with ID ${id}:`, e)
logger.error(`Failed submitting application form with ID ${id}:`, e)
return Promise.reject(e)
}
}
@@ -88,7 +90,7 @@ export function useApplicationForm() {
position
)
} catch (e: unknown) {
console.error(`Failed adding form element to subsection ${subsectionId}:`, e)
logger.error(`Failed adding form element to subsection ${subsectionId}:`, e)
return Promise.reject(e)
}
}