Add logger function to video.js Log interface (#39303)

* Add logger function to video.js Log interface

* Add logger function to video.js Log interface

* Bump version and move Definitions_by to the top

* Add video.js logger test
This commit is contained in:
KuanYu Chu
2019-10-25 13:17:22 -07:00
committed by Wesley Wigham
parent a39f3a622c
commit 8d9b48abde
2 changed files with 23 additions and 3 deletions
+10 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for Video.js 7.2
// Type definitions for Video.js 7.3
// Project: https://github.com/videojs/video.js, https://videojs.com
// Definitions by: Vincent Bortone <https://github.com/vbortone>
// Simon Clériot <https://github.com/scleriot>
@@ -10,6 +10,7 @@
// Adam Eisenreich <https://github.com/AkxeOne>
// Mei Qingguang <https://github.com/meikidd>
// Joe Flateau <https://github.com/joeflateau>
// KuanYu Chu <https://github.com/ckybonist>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
@@ -2922,6 +2923,14 @@ declare namespace videojs {
*/
(...args: any[]): void;
/**
* Make a new module or plugin and log messages with a label.
* It takes a name and gives you back a log object like videojs.log
*
* @param label
*/
createLogger: (label: string) => Log;
/**
* Logs debug messages. Similar to `console.debug`, but may also act as a comparable
* log if `console.debug` is not available
+13 -2
View File
@@ -70,6 +70,8 @@ videojs("example_video_1").ready(function() {
testPlugin(this, {});
testAugmentation(this);
testLogger();
});
function testEvents(player: videojs.Player) {
@@ -119,11 +121,20 @@ function testPlugin(player: videojs.Player, options: {}) {
}
function testAugmentation(player: videojs.Player) {
player.somePluginDefinedInAugmentation();
videojs("example_video_2", {
player.somePluginDefinedInAugmentation();
videojs("example_video_2", {
plugins: {
somePluginDefinedInAugmentation: {},
someOtherPluginNotTyped: {}
}
});
}
function testLogger() {
const mylogger = videojs.log.createLogger('mylogger');
const anotherlogger = mylogger.createLogger('anotherlogger');
videojs.log('hello');
mylogger('how are you');
anotherlogger('today');
}