Skip to content

Commit 67621af

Browse files
committed
removed unwanted logger ✔
1 parent 9453d1f commit 67621af

File tree

7 files changed

+5
-22
lines changed

7 files changed

+5
-22
lines changed

src/controllers/admin/admin.js

-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import config from 'config';
66
import bcrypt from 'bcrypt';
77

88
import { Section, Student, Staff, validateAdmin, Admin } from 'models';
9-
import logger from 'tools/logging';
109

1110
/**
1211
*
@@ -21,7 +20,6 @@ import logger from 'tools/logging';
2120

2221
export const newAdmin = async (req, res) => {
2322
const { body } = req;
24-
logger.debug('Acknowledged: ', body);
2523

2624
const { error } = validateAdmin(body);
2725
if (error) return res.status(StatusCodes.BAD_REQUEST).json({ error: error.details[0].message });
@@ -89,7 +87,6 @@ export const deleteAdmin = async (req, res) => {
8987
const {
9088
body: { id }
9189
} = req;
92-
logger.debug('Acknowledged: ', id);
9390

9491
if (!id) return res.status(StatusCodes.BAD_REQUEST).json({ error: 'id field required' });
9592

src/controllers/admin/section.js

-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import logger from 'tools/logging';
1717

1818
export const newSection = async (req, res) => {
1919
const { body } = req;
20-
logger.info('Acknowledged: ', body);
2120

2221
const { error } = validateSection(body);
2322
if (error) return res.status(StatusCodes.BAD_REQUEST).json({ error: error.details[0].message });
@@ -90,7 +89,6 @@ export const updateSectionName = async (req, res) => {
9089
const {
9190
body: { id, name }
9291
} = req;
93-
logger.debug('Acknowledged: ', id);
9492

9593
if (!id) return res.status(StatusCodes.BAD_REQUEST).json({ error: 'id field required' });
9694
if (!name) return res.status(StatusCodes.BAD_REQUEST).json({ error: 'name field required' });
@@ -124,7 +122,6 @@ export const updateSectionStaff = async (req, res) => {
124122
const {
125123
body: { id, staffId }
126124
} = req;
127-
logger.debug('Acknowledged: ', id);
128125

129126
if (!id) return res.status(StatusCodes.BAD_REQUEST).json({ error: 'id field required' });
130127
if (!staffId)
@@ -175,7 +172,6 @@ export const updateSectionStudent = async (req, res) => {
175172
const {
176173
body: { id, studentId }
177174
} = req;
178-
logger.debug('Acknowledged: ', id);
179175

180176
if (!id) return res.status(StatusCodes.BAD_REQUEST).json({ error: 'id field required' });
181177
if (!studentId)
@@ -234,7 +230,6 @@ export const removeSectionStaff = async (req, res) => {
234230
const {
235231
body: { id, staffId }
236232
} = req;
237-
logger.debug('Acknowledged: ', id);
238233

239234
if (!id) return res.status(StatusCodes.BAD_REQUEST).json({ error: 'id field required' });
240235
if (!staffId)
@@ -285,7 +280,6 @@ export const removeSectionStudent = async (req, res) => {
285280
const {
286281
body: { id, studentId }
287282
} = req;
288-
logger.debug('Acknowledged: ', id);
289283

290284
if (!id) return res.status(StatusCodes.BAD_REQUEST).json({ error: 'id field required' });
291285
if (!studentId)
@@ -331,7 +325,6 @@ export const deleteSection = async (req, res) => {
331325
const {
332326
body: { id }
333327
} = req;
334-
logger.debug('Acknowledged: ', id);
335328

336329
if (!id) return res.status(StatusCodes.BAD_REQUEST).json({ error: 'id field required' });
337330

src/controllers/admin/staff.js

-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import logger from 'tools/logging';
1818

1919
export const newStaff = async (req, res) => {
2020
const { body } = req;
21-
logger.debug('Acknowledged: ', body);
2221

2322
const { error } = validateStaff(body);
2423
if (error) return res.status(StatusCodes.BAD_REQUEST).json({ error: error.details[0].message });
@@ -100,7 +99,6 @@ export const getStaffById = async (req, res) => {
10099

101100
export const updateStaff = async (req, res) => {
102101
const { body } = req;
103-
logger.debug('Acknowledged: ', body.id);
104102

105103
if (!body.id) return res.status(StatusCodes.BAD_REQUEST).json({ error: 'id field required' });
106104

@@ -134,7 +132,6 @@ export const deleteStaff = async (req, res) => {
134132
const {
135133
body: { id }
136134
} = req;
137-
logger.debug('Acknowledged: ', id);
138135

139136
if (!id) return res.status(StatusCodes.BAD_REQUEST).json({ error: 'id field required' });
140137

src/controllers/admin/student.js

-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import logger from 'tools/logging';
1717

1818
export const newStudent = async (req, res) => {
1919
const { body } = req;
20-
logger.debug('Acknowledged: ', body);
2120

2221
const { error } = validateStudent(body);
2322
if (error) return res.status(StatusCodes.BAD_REQUEST).json({ error: error.details[0].message });
@@ -125,7 +124,6 @@ export const getStudentByRegisterNumber = async (req, res) => {
125124

126125
export const updateStudent = async (req, res) => {
127126
const { body } = req;
128-
logger.debug('Acknowledged: ', body.id);
129127

130128
if (!body.id) return res.status(StatusCodes.BAD_REQUEST).json({ error: 'id field required' });
131129

@@ -160,7 +158,6 @@ export const deleteStudent = async (req, res) => {
160158
const {
161159
body: { id }
162160
} = req;
163-
logger.debug('Acknowledged: ', id);
164161

165162
if (!id) return res.status(StatusCodes.BAD_REQUEST).json({ error: 'id field required' });
166163

src/controllers/staff.js

-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { Student, Staff, Certificate } from 'models';
2121
*/
2222
export const getStudentById = async (req, res) => {
2323
const { id } = req.params;
24-
logger.debug('Acknowleged:', id);
2524

2625
if (!id) return res.status(StatusCodes.BAD_REQUEST).json({ error: 'id field required' });
2726

@@ -103,7 +102,6 @@ export const updateStaff = async (req, res) => {
103102
const {
104103
body: { phoneNumber, email }
105104
} = req;
106-
logger.debug('Acknowledged: ', id, ' ', phoneNumber, ' ', email);
107105

108106
let fields = {
109107
phoneNumber,

src/dbConnection.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ export const dbConnection = async () => {
1616
};
1717
try {
1818
logger.debug(`Database server is at ${chalk.cyan(DB_SERVER)}`);
19-
mongoose.connect(DB_SERVER, options);
20-
await logger.info(`Database connection ${chalk.greenBright('successful')}`);
19+
await mongoose.connect(DB_SERVER, options);
20+
logger.info(`Database connection ${chalk.greenBright('successful')}`);
2121
} catch (err) {
2222
logger.error(`Database connection ${chalk.redBright('failed.')}`);
23-
logger.error(`Error: could not connect to the database at ${DB_SERVER}\n`, err);
23+
logger.error(`Error: could not connect to the database at ${DB_SERVER}\n`);
24+
logger.error(err);
2425
}
2526
};

src/middlewares/errorHandler.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { StatusCodes } from 'http-status-codes';
44
export default (err, req, res, next) => {
55
const { body } = req;
66

7-
logger.error(err.message, err);
7+
logger.error(err.message ?? err);
88

99
if (err.code === 11000) {
1010
const errorKeys = Object.keys(err.keyPattern);

0 commit comments

Comments
 (0)