Logging & Debugging
The fl-foundation
manager aims at abstracting away Platform dependent functionality and expose a platform-agnostic API for the consuming modules.
It primarily focuses on following features:
- Networking using
HttpClient
- Storage using
KeyValueStore
- Logging using
Logger
Logger
One can create a Logger using fl-foundation
library
const logger = flFoundation.createLogger(4, `FL_FOUNDATION`);
logger.warn('Warning created', { foo: 'bar' });
logger.count();
logger.error('Error created', { foo: 'bar' });
logger.info('Information created', { foo: 'bar' });
logger.debug('Debug log created', { foo: 'bar' });
logger.time('PLAYBACK_START_UP_TIME');
logger.timeEnd('PLAYBACK_START_UP_TIME');
// PLAYBACK_START_UP_TIME: 10768.51318359375ms
Following Logger Levels are supported (ordered in terms of verbosity from the most to the least):
OFF
ERROR
WARN
INFO
DEBUG
VERBOSE
Playback Logger
PlayerBuilder accepts logger and the application developers can configure a logger with their own tag information and logger levels.
const logger = flFoundation.createLogger(4, `FL_PLAYBACK_LOGS`);
const player = playerBuilder
.mediaElement(videoElement)
.mediaUrl(contentUrl)
.drmLicenseUrl(licenseUrl)
.logger(logger)
.drmScheme(flPlayer.DrmScheme.WIDEVINE)
.mediaType(flPlayer.MediaType.DASH)
.build();
Performance metrics using logger
Application develops can log the time taken to complete any operations by using time and timeEnd log api
const timerName = 'CALCULATE_START_UP_TIME';
/**
* Starts a timer you can use to track how long an operation takes.
* You give each timer a unique name and may have up to 10,000 timers
* running on a given page. When you call `timeEnd()` with the same name,
* the browser will output the time, in milliseconds, that
* elapsed since the timer was started.
*
* The name will identify the timer; use the same name when calling
* logger.timeEnd() to stop the timer and get the time output to the
* console
*/
logger.time(timerName);
logger.timeEnd(timerName);