All files / src/utils logger.ts

100% Statements 30/30
100% Branches 11/11
100% Functions 4/4
100% Lines 30/30

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 311x 1x 1x 69x 69x 1x 1x 6x 6x 1x 1x 377x 8x 8x 10x 3x 10x 5x 5x 377x 1x 1x 10x 10x 10x 3x 10x 7x 7x 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 {
  const timestamp = new Date().toISOString();
  const prefix = `[LightSDK][${tag}][ERROR]`;
  if (error !== undefined) {
    console.warn(`${prefix} ${timestamp} ${message}`, error);
  } else {
    console.warn(`${prefix} ${timestamp} ${message}`);
  }
}