-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: expose logger API #161
Conversation
set to ERROR level by default expose API to set and get log level and get log level enums expose convenience method to set logger level via global window param window.PLAYKIT_LOG_LEVEL update to JS-Logger V1.4
src/utils/logger.js
Outdated
export default lf; | ||
export {LOG_LEVEL}; | ||
export default getLogger; | ||
export {LOG_LEVEL, getLogLevel, setLogLevel}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change the var name LOG_LEVEL
to LogLevel
since it's an enum and then we can export it regularly without use the as
syntax of flow in other files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dan-ziv it's either an enum or not.
If it's an enum we should keep the convention as we do with other enums, like:
import {PLAYER_EVENTS as PlayerEvents, HTML5_EVENTS as Html5Events, CUSTOM_EVENTS as CustomEvents} from './event/events'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those conventions are wrong and already fixed in my player typing PR which you all ignore of reviewing :)
From what I see in all the lead projects the correct conventions for enums should be lead with capitals (i.e. MyEnum) and constants should be all written in capital letters (i.e. MY_CONST)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
sug.txt
Outdated
@@ -0,0 +1,107 @@ | |||
/Users/OrenMe/repos/playkit-js/src/player.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what this file for?
text.md
Outdated
// create a player | ||
var player = KalturaPlayer.setup("player-placeholder", config); | ||
|
||
var textplayer.getTracks(player.Track.TEXT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did u mean
var textTracks = player.getTracks(player.Track.TEXT);
?
text.md
Outdated
var player = KalturaPlayer.setup("player-placeholder", config); | ||
|
||
var textplayer.getTracks(player.Track.TEXT); | ||
player.selectTrack(track) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is track
?
src/player.js
Outdated
@@ -322,6 +322,9 @@ export default class Player extends FakeEventTarget { | |||
this._createPlayerContainer(); | |||
this._appendPosterEl(); | |||
this.configure(config); | |||
if (config.logLevel && this.LogLevel[config.logLevel]){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we do this in the loadPlayer
factory function of playkit.js before the initialization of the player?
in configure we already write logs and if we are doing it after it won't affect this, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see now that we are using this
for the check, but we can define fallback level in such cases and avoid this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you refer to the version and name printing in index.js, we don't want to print them and in any case these printouts are in load time before CTOR is called, and setting the config level can be done only in init time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I'm not referring to the version and name printouts.
I'm mean that you are setting the log level too late - after the configure method.
The configure method flow will print logs and seems like those logs won't have the correct log level.
Don't you think the correct place to handle the log level is before creating the player? in the loadPlayer method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the static API should remain simple IMHO.
Constructor is where everything should be setup, and in the case of logs, this line should just some before others if it's more important.
Fixed by moving to be first in line
@OrenMe |
This reverts commit 805168c.
src/player.js
Outdated
@@ -322,6 +322,9 @@ export default class Player extends FakeEventTarget { | |||
this._createPlayerContainer(); | |||
this._appendPosterEl(); | |||
this.configure(config); | |||
if (config.logLevel && this.LogLevel[config.logLevel]){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I'm not referring to the version and name printouts.
I'm mean that you are setting the log level too late - after the configure method.
The configure method flow will print logs and seems like those logs won't have the correct log level.
Don't you think the correct place to handle the log level is before creating the player? in the loadPlayer method?
src/utils/logger.js
Outdated
export default lf; | ||
export {LOG_LEVEL}; | ||
export default getLogger; | ||
export {LOG_LEVEL, getLogLevel, setLogLevel}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those conventions are wrong and already fixed in my player typing PR which you all ignore of reviewing :)
From what I see in all the lead projects the correct conventions for enums should be lead with capitals (i.e. MyEnum) and constants should be all written in capital letters (i.e. MY_CONST)
test/src/player.spec.js
Outdated
@@ -2672,3 +2671,23 @@ describe('_resetTextCuesAndReposition', function () { | |||
}); | |||
}); | |||
|
|||
describe('logger', ()=>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prettify the code in this file
src/playkit.js
Outdated
@@ -21,8 +21,8 @@ declare var __VERSION__: string; | |||
declare var __NAME__: string; | |||
declare var __PACKAGE_URL__: string; | |||
|
|||
LoggerFactory.getLogger().log(`%c ${__NAME__} ${__VERSION__}`, "color: #98ff98; font-size: large"); | |||
LoggerFactory.getLogger().log(`%c For more details see ${__PACKAGE_URL__}`, "color: #98ff98;"); | |||
getLogger().log(`%c ${__NAME__} ${__VERSION__}`, "color: #98ff98; font-size: large"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets delete those logs... ?
src/player.js
Outdated
@@ -306,6 +306,9 @@ export default class Player extends FakeEventTarget { | |||
*/ | |||
constructor(config: Object = {}) { | |||
super(); | |||
if (config.logLevel && LogLevel[config.logLevel]){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prettify
@OrenMe approved just fix codeclimate and travis (same issue) |
Description of the Changes
set to ERROR level by default
expose API to set and get log level and get log level enums
expose convenience method to set logger level via global window param window.PLAYKIT_LOG_LEVEL
update to JS-Logger V1.4
CheckLists