switch DEBUG_LOG to string handling
This commit is contained in:
@ -4,6 +4,7 @@ import { isTruthy } from '$lib/truthyString';
|
|||||||
const { DEV } = import.meta.env;
|
const { DEV } = import.meta.env;
|
||||||
|
|
||||||
export const enableVerboseLog = isTruthy(env.VERBOSE);
|
export const enableVerboseLog = isTruthy(env.VERBOSE);
|
||||||
|
export const debugLogEnv = isTruthy(DEBUG_LOG);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use the new {@link Logger} class instead.
|
* @deprecated Use the new {@link Logger} class instead.
|
||||||
@ -42,7 +43,7 @@ export class Logger {
|
|||||||
public constructor(private name: string) {}
|
public constructor(private name: string) {}
|
||||||
|
|
||||||
public static isDebugEnabled(): boolean {
|
public static isDebugEnabled(): boolean {
|
||||||
return !!DEBUG_LOG || DEV || enableVerboseLog;
|
return debugLogEnv || DEV || enableVerboseLog;
|
||||||
}
|
}
|
||||||
public verbose(...params: any[]) {
|
public verbose(...params: any[]) {
|
||||||
if (!enableVerboseLog) {
|
if (!enableVerboseLog) {
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
export function isTruthy(value: string | number | boolean | null | undefined): boolean {
|
export function isTruthy(value: string | number | boolean | null | undefined): boolean {
|
||||||
|
if (value === null || value === undefined) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
return value.toLowerCase() === 'true' || !!+value; // here we parse to number first
|
return value.toLowerCase() === 'true' || !!+value; // here we parse to number first
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user