-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
25 additions
and
21 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
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
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 |
---|---|---|
@@ -1,15 +1,19 @@ | ||
const severity = ['fatal', 'error', 'warning', 'log', 'info', 'debug', 'critical'] as const; | ||
export type Severity = typeof severity[number]; | ||
// eslint-disable-next-line @typescript-eslint/no-namespace, import/export | ||
export namespace Severity { | ||
const levels = ['fatal', 'error', 'warning', 'log', 'info', 'debug', 'critical'] as const; | ||
|
||
/** | ||
* Converts a string-based level into a {@link Severity}. | ||
* | ||
* @param level string representation of severity | ||
* @returns Severity | ||
*/ | ||
export function severityFromString(level: string): Severity { | ||
if (severity.indexOf(level as Severity) === -1) { | ||
return 'log'; | ||
export type Level = typeof levels[number]; | ||
|
||
/** | ||
* Converts a string-based level into a {@link Severity}. | ||
* | ||
* @param level string representation of severity | ||
* @returns Severity | ||
*/ | ||
export function fromString(level: string): Level { | ||
if (levels.indexOf(level as Level) === -1) { | ||
return 'log'; | ||
} | ||
return level as Level; | ||
} | ||
return level as Severity; | ||
} |