fix: Vervang console met logger
This commit is contained in:
		
							parent
							
								
									86dadeae81
								
							
						
					
					
						commit
						8f5b625cc3
					
				
					 4 changed files with 25 additions and 6 deletions
				
			
		|  | @ -7,6 +7,9 @@ import { getUrlStringForLearningObject } from '../../util/links'; | |||
| import processingService from './processing/processing-service'; | ||||
| import { NotFoundError } from '@mikro-orm/core'; | ||||
| import learningObjectService from './learning-object-service'; | ||||
| import {getLogger, Logger} from "../../logging/initalize"; | ||||
| 
 | ||||
| const logger: Logger = getLogger(); | ||||
| 
 | ||||
| function convertLearningObject(learningObject: LearningObject | null): FilteredLearningObject | null { | ||||
|     if (!learningObject) { | ||||
|  | @ -100,7 +103,7 @@ const databaseLearningObjectProvider: LearningObjectProvider = { | |||
|                     version: it.version, | ||||
|                 }); | ||||
|                 if (learningObject === null) { | ||||
|                     console.log(`WARN: Learning object corresponding with node ${it} not found!`); | ||||
|                     logger.warn(`WARN: Learning object corresponding with node ${it} not found!`); | ||||
|                 } | ||||
|                 return learningObject; | ||||
|             }) | ||||
|  |  | |||
|  | @ -10,6 +10,9 @@ import { | |||
| } from '../../interfaces/learning-content.js'; | ||||
| import dwengoApiLearningPathProvider from '../learning-paths/dwengo-api-learning-path-provider.js'; | ||||
| import { LearningObjectProvider } from './learning-object-provider'; | ||||
| import {getLogger, Logger} from "../../logging/initalize"; | ||||
| 
 | ||||
| const logger: Logger = getLogger(); | ||||
| 
 | ||||
| /** | ||||
|  * Helper function to convert the learning object metadata retrieved from the API to a FilteredLearningObject which | ||||
|  | @ -52,7 +55,7 @@ async function fetchLearningObjects(learningPathId: LearningPathIdentifier, full | |||
|         ); | ||||
| 
 | ||||
|         if (!learningPathResponse.success || !learningPathResponse.data?.length) { | ||||
|             console.error(`⚠️ WARNING: Learning path "${learningPathId.hruid}" exists but contains no learning objects.`); | ||||
|             logger.warn(`⚠️ WARNING: Learning path "${learningPathId.hruid}" exists but contains no learning objects.`); | ||||
|             return []; | ||||
|         } | ||||
| 
 | ||||
|  | @ -71,7 +74,7 @@ async function fetchLearningObjects(learningPathId: LearningPathIdentifier, full | |||
|             ) | ||||
|         ).then((objects) => objects.filter((obj): obj is FilteredLearningObject => obj !== null)); | ||||
|     } catch (error) { | ||||
|         console.error('❌ Error fetching learning objects:', error); | ||||
|         logger.error('❌ Error fetching learning objects:', error); | ||||
|         return []; | ||||
|     } | ||||
| } | ||||
|  | @ -91,7 +94,7 @@ const dwengoApiLearningObjectProvider: LearningObjectProvider = { | |||
|         ); | ||||
| 
 | ||||
|         if (!metadata || typeof metadata !== 'object') { | ||||
|             console.error(`⚠️ WARNING: Learning object "${id.hruid}" not found.`); | ||||
|             logger.warn(`⚠️ WARNING: Learning object "${id.hruid}" not found.`); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|  | @ -123,7 +126,7 @@ const dwengoApiLearningObjectProvider: LearningObjectProvider = { | |||
|         }); | ||||
| 
 | ||||
|         if (!html) { | ||||
|             console.error(`⚠️ WARNING: Learning object "${id.hruid}" not found.`); | ||||
|             logger.warn(`⚠️ WARNING: Learning object "${id.hruid}" not found.`); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,6 +2,9 @@ import { fetchWithLogging } from '../../util/apiHelper.js'; | |||
| import { DWENGO_API_BASE } from '../../config.js'; | ||||
| import { LearningPath, LearningPathResponse } from '../../interfaces/learning-content.js'; | ||||
| import { LearningPathProvider } from './learning-path-provider'; | ||||
| import {getLogger, Logger} from "../../logging/initalize"; | ||||
| 
 | ||||
| const logger: Logger = getLogger(); | ||||
| 
 | ||||
| const dwengoApiLearningPathProvider: LearningPathProvider = { | ||||
|     async fetchLearningPaths(hruids: string[], language: string, source: string): Promise<LearningPathResponse> { | ||||
|  | @ -20,7 +23,7 @@ const dwengoApiLearningPathProvider: LearningPathProvider = { | |||
|         const learningPaths = await fetchWithLogging<LearningPath[]>(apiUrl, `Learning paths for ${source}`, { params }); | ||||
| 
 | ||||
|         if (!learningPaths || learningPaths.length === 0) { | ||||
|             console.error(`⚠️ WARNING: No learning paths found for ${source}.`); | ||||
|             logger.warn(`⚠️ WARNING: No learning paths found for ${source}.`); | ||||
|             return { | ||||
|                 success: false, | ||||
|                 source, | ||||
|  |  | |||
		Reference in a new issue