-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'config-and-debug' into dev
- Loading branch information
Showing
12 changed files
with
137 additions
and
28 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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,17 @@ | ||
export type TtvcOptions = { | ||
debug?: boolean; | ||
idleTimeout?: number; | ||
}; | ||
|
||
/** ttvc configuration values set during initialization */ | ||
export const CONFIG = { | ||
/** Decide whether to log debug messages. */ | ||
DEBUG: false, | ||
/** A duration in ms to wait before declaring the page idle. */ | ||
IDLE_TIMEOUT: 200, | ||
}; | ||
|
||
export const setConfig = (options?: TtvcOptions) => { | ||
if (options?.debug) CONFIG.DEBUG = options.debug; | ||
if (options?.idleTimeout) CONFIG.IDLE_TIMEOUT = options.idleTimeout; | ||
}; |
File renamed without changes.
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,22 @@ | ||
import {CONFIG} from './constants'; | ||
|
||
export class Logger { | ||
private static format(...messages: unknown[]) { | ||
return ['[ttvc]', ...messages, '::', performance.now()]; | ||
} | ||
/** Log a debug message to the console */ | ||
static debug(...messages: unknown[]) { | ||
if (!CONFIG.DEBUG) return; | ||
console.debug(...this.format(...messages)); | ||
} | ||
/** Log a message to the console */ | ||
static info(...messages: unknown[]) { | ||
if (!CONFIG.DEBUG) return; | ||
console.info(...this.format(...messages)); | ||
} | ||
/** Log a warning message to the console */ | ||
static warn(...messages: unknown[]) { | ||
if (!CONFIG.DEBUG) return; | ||
console.warn(...this.format(...messages)); | ||
} | ||
} |
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