Compare commits

..

1 Commits

Author SHA1 Message Date
80fbd915ed Use winston for logging 2021-03-14 21:14:44 -06:00
2 changed files with 6 additions and 11 deletions

View File

@ -59,7 +59,7 @@ async function initSonar() {
}
`
);
logger.info(`Authenticated to Sonar as '${user.me.name}'`);
logger.info(`Authenticated to Sonar as '${user.me.name}'.`);
return sonar;
}
@ -88,11 +88,11 @@ async function initRingCentralSDK() {
platform.on(platform.events.refreshError, async (err) => {
logger.error("Refresh token error:", err);
await login();
logger.info("RingCentral re-authentication successful");
logger.info("RingCentral re-authentication successful.");
});
await login();
logger.info("Authenticated to RingCentral");
logger.info("Authenticated to RingCentral.");
return sdk;
}
@ -101,7 +101,7 @@ async function initDB() {
const db = knex(knexConfig);
if (!process.env.DB_SKIP_MIGRATIONS) {
await db.migrate.latest();
logger.info("Database migrations run successfully");
logger.info("Database migrations run successfully.");
}
return db;
}
@ -114,10 +114,9 @@ async function main() {
const rcsdk = await initRingCentralSDK();
const db = await initDB();
logger.info("Starting ticketizer...");
const intervals = ticketize(sonar, rcsdk, db, getTicketizeConfig());
logger.info("Started");
["SIGINT", "SIGTERM", "SIGQUIT"].forEach((sig) => {
process.on(sig, async () => {
logger.info(`\nCaught ${sig}, shutting down...`);
@ -131,7 +130,6 @@ async function main() {
logger.error(result.reason);
}
});
await rcsdk.logout();
process.exit(errors ? 1 : 0);
});
});

View File

@ -5,10 +5,7 @@ export const DEBUG = !!process.env.DEBUG;
export const logger = winston.createLogger({
level: DEBUG ? "debug" : process.env.LOG_LEVEL ?? "info",
transports: [new winston.transports.Console()],
format: format.combine(
format.errors({ stack: true }),
format.printf(({ level, message }) => `${level}: ${message}`)
),
format: format.printf(({ level, message }) => `${level}: ${message}`),
});
export function getNationalNumber(input: string) {