refactor(backend): logger i.p.v. console
This commit is contained in:
parent
30ec73a88d
commit
c14d6c53da
9 changed files with 30 additions and 22 deletions
|
@ -1,6 +1,7 @@
|
|||
import { DWENGO_API_BASE } from '../config.js';
|
||||
import { fetchWithLogging } from '../util/api-helper.js';
|
||||
import { FilteredLearningObject, LearningObjectMetadata, LearningObjectNode, LearningPathResponse } from '../interfaces/learning-content.js';
|
||||
import { getLogger } from '../logging/initalize.js';
|
||||
|
||||
function filterData(data: LearningObjectMetadata, htmlUrl: string): FilteredLearningObject {
|
||||
return {
|
||||
|
@ -37,7 +38,7 @@ export async function getLearningObjectById(hruid: string, language: string): Pr
|
|||
);
|
||||
|
||||
if (!metadata) {
|
||||
console.error(`⚠️ WARNING: Learning object "${hruid}" not found.`);
|
||||
getLogger().error(`⚠️ WARNING: Learning object "${hruid}" not found.`);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -53,7 +54,7 @@ async function fetchLearningObjects(hruid: string, full: boolean, language: stri
|
|||
const learningPathResponse: LearningPathResponse = await fetchLearningPaths([hruid], language, `Learning path for HRUID "${hruid}"`);
|
||||
|
||||
if (!learningPathResponse.success || !learningPathResponse.data?.length) {
|
||||
console.error(`⚠️ WARNING: Learning path "${hruid}" exists but contains no learning objects.`);
|
||||
getLogger().error(`⚠️ WARNING: Learning path "${hruid}" exists but contains no learning objects.`);
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -67,7 +68,7 @@ async function fetchLearningObjects(hruid: string, full: boolean, language: stri
|
|||
objects.filter((obj): obj is FilteredLearningObject => obj !== null)
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('❌ Error fetching learning objects:', error);
|
||||
getLogger().error('❌ Error fetching learning objects:', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue