Skip to content

Commit

Permalink
feat(utils/logger): exits messages are logged w/ the same level as kp…
Browse files Browse the repository at this point in the history
…o's ones
  • Loading branch information
rafamel committed May 11, 2019
1 parent 5de16eb commit c4333be
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import loglevel from 'loglevel';
import chalk, { Chalk } from 'chalk';
import { DEFAULT_LOG_LEVEL } from '~/constants';
import { TLogger } from '~/types';
import { options } from 'exits';

const APP_NAME = 'kpo';
const logger = loglevel.getLogger(`_${APP_NAME}_logger_`);

function setLevel(level: TLogger): void {
logger.setLevel(level);
options({ logger: level });
}

const colors: { [key in TLogger]?: Chalk } = {
Expand Down Expand Up @@ -39,5 +41,6 @@ logger.methodFactory = (...args) => (...inner: any[]) => {

// Must be set -at least once- after overwriting methodFactory
logger.setDefaultLevel(DEFAULT_LOG_LEVEL);
options({ logger: DEFAULT_LOG_LEVEL });

export { logger as default, setLevel };

0 comments on commit c4333be

Please sign in to comment.