Skip to content

Commit

Permalink
improve log level mgmt
Browse files Browse the repository at this point in the history
  • Loading branch information
bcollard committed Feb 12, 2024
1 parent b3f1010 commit 04eae8e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions api/app/postgresql.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const items = require("../db/items.json");
const { Pool } = require("pg");
const pino = require('pino');
const logger = pino({ name: 'kuma-backend-pg' });
const logger = pino({ name: 'kuma-backend-pg', level: process.env.PINO_LOG_LEVEL || 'info' });
const dns = require('dns');
const dnsPromises = dns.promises;

Expand All @@ -26,7 +26,7 @@ pool.on("error", (err, clients) => {

const search = async (itemName) => {
const poolDetails = await asyncStringify(pool);
await logger.info('pool details: ' + poolDetails);
await logger.debug('pool details: ' + poolDetails);
await dnsPromises.lookup(pool.options.host, dnsOptions).then(async (result) => {
await logger.info('DNS lookup for host ' + pool.options.host + ': %j', result);
});
Expand Down Expand Up @@ -61,7 +61,7 @@ const importData = () => {
await client.query("ROLLBACK");
throw e;
} finally {
logger.info("Release");
logger.debug("Release");
client.release();
}
})().catch((e) => logger.error(e.stack));
Expand Down
2 changes: 1 addition & 1 deletion api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const redis = require("./app/redis");
const postgresql = require("./app/postgresql");
const promBundle = require("express-prom-bundle");
const pino = require('pino');
const logger = pino({ name: 'kuma-backend' });
const logger = pino({ name: 'kuma-backend', level: process.env.PINO_LOG_LEVEL || 'info' });

const express = require("express");
const app = express();
Expand Down

0 comments on commit 04eae8e

Please sign in to comment.