Skip to content

Commit

Permalink
chore(logging): use and fix logging information
Browse files Browse the repository at this point in the history
  • Loading branch information
noxiousghost committed Dec 27, 2024
1 parent fcc07df commit 809a8d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/database/db.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { Module } from '@nestjs/common';
import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm';
import { dataBaseConfigurations } from 'src/scripts/orm.config';
import { DataSource, DataSourceOptions, TypeORMError } from 'typeorm';
import { Logger } from '@nestjs/common';

const logger = new Logger();

@Module({
imports: [
Expand All @@ -15,7 +18,7 @@ import { DataSource, DataSourceOptions, TypeORMError } from 'typeorm';
dataSourceFactory: async (options: DataSourceOptions) => {
try {
const dataSource = await new DataSource(options).initialize();
console.log(' ------ Connected to Database successfully -----');
logger.log(' ------ Connected to Database successfully -----');
return dataSource;
} catch (error) {
throw new TypeORMError(`Error Connection to database , "${error}"`);
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/orm.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
entities: [join(__dirname, '/../entities', '*.entity.{ts,js}')],
migrations: [join(__dirname, '/../migrations', '*.{ts,js}')],
};
Expand Down

0 comments on commit 809a8d5

Please sign in to comment.