Skip to content

bug: backend fails to start because src/utils/logger.js is missing#1081

Open
sonusharma6-dsa wants to merge 2 commits into
souma9830:masterfrom
sonusharma6-dsa:fix/missing-logger
Open

bug: backend fails to start because src/utils/logger.js is missing#1081
sonusharma6-dsa wants to merge 2 commits into
souma9830:masterfrom
sonusharma6-dsa:fix/missing-logger

Conversation

@sonusharma6-dsa

Copy link
Copy Markdown

Closes #1032. Adds the missing backend logger.js utility wrapping standard console methods with formatted levels and ISO timestamps, enabling the backend service to start successfully.

Copilot AI review requested due to automatic review settings July 2, 2026 15:54
@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

@sonusharma6-dsa is attempting to deploy a commit to the souma9830's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR primarily resolves backend startup failures by adding the missing backend/src/utils/logger.js module that is imported by the app and env checks. It also includes changes to upload persistence behavior and schema shape.

Changes:

  • Add backend/src/utils/logger.js as a lightweight console wrapper with timestamped log levels.
  • Modify upload persistence to always create an Upload record (including anonymous uploads) and record the stored filename.
  • Update the Upload schema to make user optional and introduce a required filename field.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
backend/src/utils/logger.js Adds the previously-missing logger module required for backend imports to resolve.
backend/src/models/upload.model.js Updates the upload schema to support anonymous uploads and to require/stash filename.
backend/src/controllers/upload.controller.js Persists uploads for anonymous users and includes filename in stored metadata/response.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +21
/**
* Simple custom logger wrapping console methods with formatted timestamps and levels.
*/
const logger = {
info: (msg, ...args) => {
console.log(`[${new Date().toISOString()}] [INFO]: ${msg}`, ...args);
},
warn: (msg, ...args) => {
console.warn(`[${new Date().toISOString()}] [WARN]: ${msg}`, ...args);
},
error: (msg, ...args) => {
console.error(`[${new Date().toISOString()}] [ERROR]: ${msg}`, ...args);
},
debug: (msg, ...args) => {
if (process.env.NODE_ENV !== 'production') {
console.debug(`[${new Date().toISOString()}] [DEBUG]: ${msg}`, ...args);
}
}
};

export default logger;
Comment on lines +46 to +54
await Upload.create({
user: req.user?.id || null,
fileId,
filename: req.file.filename,
originalName: req.file.originalname,
fileUrl,
mimeType: req.file.mimetype,
sizeBytes: req.file.size,
});
Comment on lines 5 to 9
user: {
type: mongoose.Schema.Types.ObjectId,
ref: "User",
required: true,
required: false, // Optional for anonymous uploads
},
@souma9830

Copy link
Copy Markdown
Owner

Open Source Programmed name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: backend fails to start because src/utils/logger.js is missing

3 participants