refactor: Verbeter logging
This commit is contained in:
		
							parent
							
								
									a1635b9db4
								
							
						
					
					
						commit
						f8035099c9
					
				
					 3 changed files with 15 additions and 6 deletions
				
			
		|  | @ -4,6 +4,8 @@ | ||||||
| # Should not need to be modified. | # Should not need to be modified. | ||||||
| # See .env.example for more information. | # See .env.example for more information. | ||||||
| # | # | ||||||
|  | ### Advanced configuration ### | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| ### Dwengo ### | ### Dwengo ### | ||||||
| 
 | 
 | ||||||
|  | @ -20,3 +22,7 @@ DWENGO_AUTH_TEACHER_CLIENT_ID=dwengo | ||||||
| DWENGO_AUTH_TEACHER_JWKS_ENDPOINT=http://localhost:7080/realms/teacher/protocol/openid-connect/certs | DWENGO_AUTH_TEACHER_JWKS_ENDPOINT=http://localhost:7080/realms/teacher/protocol/openid-connect/certs | ||||||
| 
 | 
 | ||||||
| DWENGO_CORS_ALLOWED_ORIGINS=http://localhost:5173,http://localhost:3000,http://localhost:9876,* | DWENGO_CORS_ALLOWED_ORIGINS=http://localhost:5173,http://localhost:3000,http://localhost:9876,* | ||||||
|  | 
 | ||||||
|  | ### Advanced configuration ### | ||||||
|  | 
 | ||||||
|  | DWENGO_LOGGING_LEVEL=debug | ||||||
|  |  | ||||||
|  | @ -7,12 +7,17 @@ let orm: MikroORM | undefined; | ||||||
| export async function initORM(testingMode = false): Promise<MikroORM<IDatabaseDriver, EntityManager>> { | export async function initORM(testingMode = false): Promise<MikroORM<IDatabaseDriver, EntityManager>> { | ||||||
|     const logger: Logger = getLogger(); |     const logger: Logger = getLogger(); | ||||||
| 
 | 
 | ||||||
|     logger.info('Initializing ORM'); |     const options = config(testingMode); | ||||||
|     logger.debug('MikroORM config is', config); | 
 | ||||||
|  |     logger.info('MikroORM config is', options); | ||||||
|  | 
 | ||||||
|  |     logger.info('Initializing ORM'); | ||||||
|  |     orm = await MikroORM.init(options); | ||||||
|  |     logger.info('MikroORM initialized'); | ||||||
| 
 | 
 | ||||||
|     orm = await MikroORM.init(config(testingMode)); |  | ||||||
|     // Update the database scheme if necessary and enabled.
 |     // Update the database scheme if necessary and enabled.
 | ||||||
|     if (getEnvVar(envVars.DbUpdate)) { |     if (getEnvVar(envVars.DbUpdate)) { | ||||||
|  |         logger.info("MikroORM: Updating database schema"); | ||||||
|         await orm.schema.updateSchema(); |         await orm.schema.updateSchema(); | ||||||
|     } else { |     } else { | ||||||
|         const diff = await orm.schema.getUpdateSchemaSQL(); |         const diff = await orm.schema.getUpdateSchemaSQL(); | ||||||
|  |  | ||||||
|  | @ -77,6 +77,4 @@ export async function seedDatabase(envFile = '.env.development.local', testMode | ||||||
|     await orm.close(); |     await orm.close(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| seedDatabase().catch((err) => { | seedDatabase().catch((err) => logger.error(`Seeding: ${err}`)); | ||||||
|     logger.error(err); |  | ||||||
| }); |  | ||||||
|  |  | ||||||
		Reference in a new issue