-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
6 changed files
with
57 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { isNumber, isString } from '../data/is' | ||
import { getGlobalLogger } from './log' | ||
import type { LogLevelAliasType, LoggerInterface } from './log-base' | ||
|
||
/** | ||
* Simple log configuration for use in modular scenarios. | ||
* | ||
* `LogConfig` can be of various types: | ||
* | ||
* 1. `LoggerInterface`: Just a complete logger howeveryou like it | ||
* 2. `true`: The default logger on | ||
* 3. `string`: Logger with name | ||
* 4. `number`: Logger with level e.g. set to `0` to see all | ||
* | ||
* All others turn it off. | ||
*/ | ||
export type LogConfig = LoggerInterface | string | number | null | undefined | boolean | ||
|
||
/** See LogConfig */ | ||
export function _LoggerFromConfig( | ||
Logger: (name?: string, level?: LogLevelAliasType) => LoggerInterface, | ||
config: LogConfig, | ||
name: string, | ||
level?: LogLevelAliasType, | ||
): LoggerInterface { | ||
if (config === true) | ||
return Logger(name, level) | ||
if (isString(config) && config.length > 0) | ||
return Logger(config, level) | ||
if (isNumber(config)) | ||
return Logger(name, config) | ||
if (typeof config === 'function') | ||
return config | ||
return Logger(name, false) | ||
} |
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