Skip to content
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

Merged
merged 20 commits into from
Nov 14, 2017
Merged

feat: expose logger API #161

merged 20 commits into from
Nov 14, 2017

Conversation

OrenMe
Copy link
Contributor

@OrenMe OrenMe commented Nov 11, 2017

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

  • changes have been done against master branch, and PR does not conflict
  • new unit / functional tests have been added (whenever applicable)
  • test are passing in local environment
  • Travis tests are passing (or test results are not worse than on master branch :))
  • Docs have been updated

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
@OrenMe OrenMe self-assigned this Nov 11, 2017
@OrenMe OrenMe changed the title Logger refactor feat: expose logger API Nov 11, 2017
export default lf;
export {LOG_LEVEL};
export default getLogger;
export {LOG_LEVEL, getLogLevel, setLogLevel};
Copy link
Contributor

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

Copy link
Contributor Author

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'

Copy link
Contributor

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)

Copy link
Contributor Author

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
Copy link
Contributor

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);
Copy link
Contributor

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)
Copy link
Contributor

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]){
Copy link
Contributor

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?

Copy link
Contributor

@dan-ziv dan-ziv Nov 12, 2017

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

Copy link
Contributor Author

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

Copy link
Contributor

@dan-ziv dan-ziv Nov 12, 2017

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?

Copy link
Contributor Author

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

@dan-ziv
Copy link
Contributor

dan-ziv commented Nov 12, 2017

@OrenMe
What are
cov.json
and
sug.txt
?

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]){
Copy link
Contributor

@dan-ziv dan-ziv Nov 12, 2017

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?

export default lf;
export {LOG_LEVEL};
export default getLogger;
export {LOG_LEVEL, getLogLevel, setLogLevel};
Copy link
Contributor

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)

@@ -2672,3 +2671,23 @@ describe('_resetTextCuesAndReposition', function () {
});
});

describe('logger', ()=>{
Copy link
Contributor

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");
Copy link
Contributor

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]){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prettify

@dan-ziv
Copy link
Contributor

dan-ziv commented Nov 14, 2017

@OrenMe approved just fix codeclimate and travis (same issue)

@dan-ziv dan-ziv merged commit f61dce4 into master Nov 14, 2017
@dan-ziv dan-ziv deleted the loggerRefactor branch November 14, 2017 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants