mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
chore: Fix lint after rebase
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
69324ff555
commit
369f934159
11 files changed
+67
-46
No files matched your search
@@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
extends: "@k8slens/eslint-config/eslint",
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
},
|
||||
};
|
||||
@@ -38,7 +38,7 @@
|
||||
"winston": "^3.8.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@k8slens/eslint-config": "6.5.0-alpha.1",
|
||||
"@k8slens/eslint-config": "^6.5.0",
|
||||
"@k8slens/jest": "^6.5.0",
|
||||
"@k8slens/react-testing-library-discovery": "^1.0.0",
|
||||
"@k8slens/webpack": "^6.5.0"
|
||||
|
||||
@@ -20,6 +20,25 @@ export interface Logger {
|
||||
silly: LogFunction;
|
||||
}
|
||||
|
||||
const screamingKebabCase = (str: string) => pipeline(str, kebabCase, toUpper);
|
||||
|
||||
const getLogFunctionFor = (
|
||||
scenario: keyof Logger,
|
||||
namespace: string | undefined
|
||||
) => {
|
||||
const prefix = namespace
|
||||
? `[${screamingKebabCase(namespace.replace(/-feature$/, ""))}]: `
|
||||
: "";
|
||||
|
||||
return (di: DiContainerForInjection): LogFunction => {
|
||||
const winstonLogger = di.inject(winstonLoggerInjectable);
|
||||
|
||||
return (message, ...data) => {
|
||||
winstonLogger[scenario](`${prefix}${message}`, ...data);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/** @deprecated Use specific injectionToken, eg. logErrorInjectionToken */
|
||||
export const loggerInjectionToken = getInjectionToken<Logger>({
|
||||
id: "logger-injection-token",
|
||||
@@ -61,25 +80,6 @@ export const logSillyInjectionToken = getInjectionToken<LogFunction>({
|
||||
id: "log-silly-injection-token",
|
||||
});
|
||||
|
||||
const screamingKebabCase = (str: string) => pipeline(str, kebabCase, toUpper);
|
||||
|
||||
const getLogFunctionFor = (
|
||||
scenario: keyof Logger,
|
||||
namespace: string | undefined
|
||||
) => {
|
||||
const prefix = namespace
|
||||
? `[${screamingKebabCase(namespace.replace(/-feature$/, ""))}]: `
|
||||
: "";
|
||||
|
||||
return (di: DiContainerForInjection): LogFunction => {
|
||||
const winstonLogger = di.inject(winstonLoggerInjectable);
|
||||
|
||||
return (message, ...data) => {
|
||||
winstonLogger[scenario](`${prefix}${message}`, ...data);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const logDebugInjectable = getInjectable({
|
||||
id: "log-debug",
|
||||
instantiate: (di) => getLogFunctionFor("debug", di.sourceNamespace)(di),
|
||||
|
||||
Reference in new issue
Block a user