Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add verbosity flag to CLI (#214)
This adds a --verbosity flag, which defaults to WARNING. Skipped links now are hidden by default, unless verbosity is set to INFO or DEBUG.
- Loading branch information
1 parent
7c84936
commit d20cff5
Showing
4 changed files
with
212 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
export enum LogLevel { | ||
DEBUG = 0, | ||
INFO = 1, | ||
WARNING = 2, | ||
ERROR = 3, | ||
NONE = 4, | ||
} | ||
|
||
export enum Format { | ||
TEXT, | ||
JSON, | ||
CSV, | ||
} | ||
|
||
export class Logger { | ||
public level: LogLevel; | ||
public format: Format; | ||
|
||
constructor(level: LogLevel, format: Format) { | ||
this.level = level; | ||
this.format = format; | ||
} | ||
|
||
debug(message?: string) { | ||
if (this.level <= LogLevel.DEBUG && this.format === Format.TEXT) { | ||
console.debug(message); | ||
} | ||
} | ||
|
||
info(message?: string) { | ||
if (this.level <= LogLevel.INFO && this.format === Format.TEXT) { | ||
console.info(message); | ||
} | ||
} | ||
|
||
warn(message?: string) { | ||
if (this.level <= LogLevel.WARNING && this.format === Format.TEXT) { | ||
// note: this is `console.log` on purpose. `console.warn` maps to | ||
// `console.error`, which would print these messages to stderr. | ||
console.log(message); | ||
} | ||
} | ||
|
||
error(message?: string) { | ||
if (this.level <= LogLevel.ERROR) { | ||
console.error(message); | ||
} | ||
} | ||
} |
Oops, something went wrong.