Skip to content

Commit

Permalink
feat(utils/logger): adds logger
Browse files Browse the repository at this point in the history
  • Loading branch information
rafamel committed Apr 11, 2019
1 parent 74e1ed2 commit 78676b4
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 1 deletion.
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@
"typescript": "^3.4.2"
},
"dependencies": {
"@types/loglevel": "^1.5.4",
"find-up": "^3.0.0",
"lodash.clone": "^4.5.0",
"loglevel": "^1.6.1",
"pify": "^4.0.1",
"spawn-command": "0.0.2-1"
},
Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Default configuration file name
export const FILE_NAME = 'kpo.scripts';
// Default logging level
export const DEFAULT_LOG_LEVEL = 'info';
// Default stdio for spawned commands
export const DEFAULT_STDIO = 'inherit';
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default function main(): void {}
export * from './types';
3 changes: 3 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { LogLevelDesc } from 'loglevel';

export type TLogger = LogLevelDesc;
11 changes: 11 additions & 0 deletions src/utils/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import loglevel from 'loglevel';
import { DEFAULT_LOG_LEVEL } from '~/constants';
import { TLogger } from '~/types';

const logger = loglevel.getLogger('_kpo_logger_');
logger.setDefaultLevel(DEFAULT_LOG_LEVEL);

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

0 comments on commit 78676b4

Please sign in to comment.