mirror of
https://github.com/muerwre/vk-tg-bot.git
synced 2025-04-24 22:46:41 +07:00
#5 restricted db logging to debug only
This commit is contained in:
parent
70ce0bff1c
commit
2af91bbf0d
2 changed files with 7 additions and 3 deletions
|
@ -10,7 +10,7 @@ async function main() {
|
|||
try {
|
||||
const config = prepareConfig();
|
||||
|
||||
const db = new PostgresDB(config.postgres);
|
||||
const db = new PostgresDB(config.postgres, config.logger);
|
||||
await db.connect();
|
||||
|
||||
const telegram = new TelegramService(config.telegram);
|
||||
|
|
|
@ -7,6 +7,7 @@ import path from "path";
|
|||
import { Like } from "./entities/Like";
|
||||
import { Event } from "./entities/Event";
|
||||
import { Post } from "./entities/Post";
|
||||
import { LoggerConfig } from "../../logger/types";
|
||||
|
||||
const entities = [path.join(__dirname, "./entities/*")];
|
||||
|
||||
|
@ -16,7 +17,10 @@ export class PostgresDB implements Storage {
|
|||
private likes!: Repository<Like>;
|
||||
private posts!: Repository<Post>;
|
||||
|
||||
constructor(private config: PostgresConfig) {}
|
||||
constructor(
|
||||
private config: PostgresConfig,
|
||||
private loggerConfig: LoggerConfig
|
||||
) {}
|
||||
|
||||
connect = async () => {
|
||||
logger.info(`connecting to ${this.config.uri}`);
|
||||
|
@ -25,7 +29,7 @@ export class PostgresDB implements Storage {
|
|||
type: "postgres",
|
||||
url: this.config.uri,
|
||||
entities,
|
||||
logging: true,
|
||||
logging: this.loggerConfig.level === "debug",
|
||||
synchronize: true,
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue