chore(backend): Switch console naar logger

Maak gebruik van custom logger
This commit is contained in:
Tibo De Peuter 2025-03-02 15:14:26 +01:00
parent f82668148c
commit c2e3886f3f
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
6 changed files with 29 additions and 13 deletions

View file

@ -7,6 +7,10 @@ import {
LearningPathResponse,
} from '../interfaces/learningPath.js';
import { fetchLearningPaths } from './learningPaths.js';
import { getLogger } from '../logging/initalize.js';
import { Logger } from 'winston';
const logger: Logger = getLogger();
function filterData(
data: LearningObjectMetadata,
@ -49,7 +53,7 @@ export async function getLearningObjectById(
);
if (!metadata) {
console.error(`⚠️ WARNING: Learning object "${hruid}" not found.`);
logger.error(`⚠️ WARNING: Learning object "${hruid}" not found.`);
return null;
}
@ -77,7 +81,7 @@ async function fetchLearningObjects(
!learningPathResponse.success ||
!learningPathResponse.data?.length
) {
console.error(
logger.error(
`⚠️ WARNING: Learning path "${hruid}" exists but contains no learning objects.`
);
return [];
@ -104,7 +108,7 @@ async function fetchLearningObjects(
});
});
} catch (error) {
console.error('❌ Error fetching learning objects:', error);
logger.error('❌ Error fetching learning objects:', error);
return [];
}
}

View file

@ -4,6 +4,10 @@ import {
LearningPath,
LearningPathResponse,
} from '../interfaces/learningPath.js';
import { getLogger } from '../logging/initalize.js';
import { Logger } from 'winston';
const logger: Logger = getLogger();
export async function fetchLearningPaths(
hruids: string[],
@ -29,7 +33,7 @@ export async function fetchLearningPaths(
);
if (!learningPaths || learningPaths.length === 0) {
console.error(`⚠️ WARNING: No learning paths found for ${source}.`);
logger.error(`⚠️ WARNING: No learning paths found for ${source}.`);
return {
success: false,
source,