All files / src/utils logger.ts

100% Statements 31/31
100% Branches 13/13
100% Functions 4/4
100% Lines 31/31

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 321x 1x 1x 42x 42x 1x 1x 6x 6x 1x 1x 289x 8x 8x 10x 3x 10x 5x 5x 289x 1x 1x 10x 8x 8x 10x 3x 10x 5x 5x 10x  
let debugEnabled = false;
 
export function setDebug(enabled: boolean): void {
  debugEnabled = enabled;
}
 
export function isDebugEnabled(): boolean {
  return debugEnabled;
}
 
export function logDebug(tag: string, message: string, data?: unknown): void {
  if (!debugEnabled) return;
  const timestamp = new Date().toISOString();
  const prefix = `[LightSDK][${tag}]`;
  if (data !== undefined) {
    console.log(`${prefix} ${timestamp} ${message}`, data);
  } else {
    console.log(`${prefix} ${timestamp} ${message}`);
  }
}
 
export function logError(tag: string, message: string, error?: unknown): void {
  if (!debugEnabled) return;
  const timestamp = new Date().toISOString();
  const prefix = `[LightSDK][${tag}][ERROR]`;
  if (error !== undefined) {
    console.error(`${prefix} ${timestamp} ${message}`, error);
  } else {
    console.error(`${prefix} ${timestamp} ${message}`);
  }
}