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
|
|
@ -9,6 +9,7 @@ import {
|
|||
import { Group } from '../entities/assignments/group.entity.js';
|
||||
import { GroupDTO, mapToGroupDTO, mapToGroupDTOId } from '../interfaces/group.js';
|
||||
import { mapToSubmissionDTO, SubmissionDTO } from '../interfaces/submission.js';
|
||||
import { getLogger } from '../logging/initalize.js';
|
||||
|
||||
export async function getGroup(classId: string, assignmentNumber: number, groupNumber: number, full: boolean): Promise<GroupDTO | null> {
|
||||
const classRepository = getClassRepository();
|
||||
|
|
@ -45,7 +46,7 @@ export async function createGroup(groupData: GroupDTO, classid: string, assignme
|
|||
const memberUsernames = (groupData.members as string[]) || []; // TODO check if groupdata.members is a list
|
||||
const members = (await Promise.all([...memberUsernames].map((id) => studentRepository.findByUsername(id)))).filter((student) => student != null);
|
||||
|
||||
console.log(members);
|
||||
getLogger().debug(members);
|
||||
|
||||
const classRepository = getClassRepository();
|
||||
const cls = await classRepository.findById(classid);
|
||||
|
|
@ -71,7 +72,7 @@ export async function createGroup(groupData: GroupDTO, classid: string, assignme
|
|||
|
||||
return newGroup;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
getLogger().error(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -95,8 +96,7 @@ export async function getAllGroups(classId: string, assignmentNumber: number, fu
|
|||
const groups = await groupRepository.findAllGroupsForAssignment(assignment);
|
||||
|
||||
if (full) {
|
||||
console.log('full');
|
||||
console.log(groups);
|
||||
getLogger().debug({ full: full, groups: groups });
|
||||
return groups.map(mapToGroupDTO);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 [];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { mapToStudent, mapToStudentDTO, StudentDTO } from '../interfaces/student
|
|||
import { mapToSubmissionDTO, SubmissionDTO } from '../interfaces/submission.js';
|
||||
import { getAllAssignments } from './assignments.js';
|
||||
import { UserService } from './users.js';
|
||||
import { getLogger } from '../logging/initalize.js';
|
||||
|
||||
export async function getAllStudents(): Promise<StudentDTO[]> {
|
||||
const studentRepository = getStudentRepository();
|
||||
|
|
@ -35,7 +36,7 @@ export async function createStudent(userData: StudentDTO): Promise<StudentDTO |
|
|||
|
||||
return mapToStudentDTO(newStudent);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
getLogger().error(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -54,7 +55,7 @@ export async function deleteStudent(username: string): Promise<StudentDTO | null
|
|||
|
||||
return mapToStudentDTO(user);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
getLogger().error(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import { mapToQuestionDTO, mapToQuestionId, QuestionDTO, QuestionId } from '../i
|
|||
import { UserService } from './users.js';
|
||||
import { mapToUser } from '../interfaces/user.js';
|
||||
import { mapToTeacher, mapToTeacherDTO, TeacherDTO } from '../interfaces/teacher.js';
|
||||
import { getLogger } from '../logging/initalize.js';
|
||||
|
||||
export async function getAllTeachers(): Promise<TeacherDTO[]> {
|
||||
const teacherRepository = getTeacherRepository();
|
||||
|
|
@ -40,7 +41,7 @@ export async function createTeacher(userData: TeacherDTO): Promise<TeacherDTO |
|
|||
|
||||
return mapToTeacherDTO(newTeacher);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
getLogger().error(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -59,7 +60,7 @@ export async function deleteTeacher(username: string): Promise<TeacherDTO | null
|
|||
|
||||
return mapToTeacherDTO(user);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
getLogger().error(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue