Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDT24-24 | Create logger wrapper #10

Merged
merged 4 commits into from
Dec 31, 2024
Merged

PDT24-24 | Create logger wrapper #10

merged 4 commits into from
Dec 31, 2024

Conversation

noxiousghost
Copy link
Collaborator

Tasks

Changes

  • Setup winston and Nest-winston for creating a custom logger.
  • Overwritten the default nestjs logger with new winston logger.

Notes

  • Now the logging behavior of the application depends upon the APP_ENV environment variable. In production, the logs are saved in /logs/all.log and /logs/error.log files and in development, the logs are simply printed in console.

@@ -6,7 +6,7 @@ services:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
ports:
- 5432:5432
- 5433:5432
Copy link
Collaborator

Choose a reason for hiding this comment

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

5432:5432 chai kina hatako ? eutai rakhda ni hunxa hola

Copy link
Collaborator Author

@noxiousghost noxiousghost Dec 30, 2024

Choose a reason for hiding this comment

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

I already have postgres installed in my main machine and I assume most of the people already have it too so keeping 5432 is causing port conflict.

new transports.File({ filename: 'logs/errors.log', level: 'error' }),
new transports.File({ filename: 'logs/all.log' }),
]
: [new transports.Console({ format: format.combine(format.colorize({ all: true })) })],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wont there be logger file for development ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we can check all the logs in our console in development.

@@ -0,0 +1,16 @@
import { format, transports } from 'winston';
const isProduction = process.env.APP_ENV === 'production';
Copy link
Collaborator

@pratham-outside pratham-outside Dec 30, 2024

Choose a reason for hiding this comment

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

After merging PDT24-25 lets use env.NODE_ENV ===APP_ENVIRONVENT.PRODUCTION

@@ -9,7 +9,7 @@ const dataBaseConfigurations = {
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_DB,
synchronize: false, // Should be false in production to use migrations
logging: true,
logging: process.env.APP_ENV === 'production' ? false : true,
Copy link
Collaborator

@pratham-outside pratham-outside Dec 30, 2024

Choose a reason for hiding this comment

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

env.NODE_ENV === APP_ENVIRONVENT.PRODUCTION ? false: true

@noxiousghost noxiousghost changed the base branch from main to PDT24-45 December 30, 2024 10:22
@noxiousghost noxiousghost self-assigned this Dec 30, 2024
noxiousghost and others added 2 commits December 31, 2024 11:31
* feat: configure nodemailer servie for sending email

* feat: create a basic email template for sending signup otp code

* chore: rename param names and add function documentation

* fix: use secure mailing port

* refactor: remove sendEmail call from main and improve sendEmail method
Copy link

@noxiousghost noxiousghost merged commit 0947ed2 into PDT24-45 Dec 31, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants