Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

feat(logger): Add log level configuration (#1451) #4068

Merged
merged 1 commit into from
Feb 12, 2018

Conversation

bcaudan
Copy link
Contributor

@bcaudan bcaudan commented Feb 5, 2017

No description provided.

@bcaudan
Copy link
Contributor Author

bcaudan commented Mar 8, 2017

Is there anything I could do to help this PR to be merged?

Copy link
Contributor

@NickTomlin NickTomlin left a comment

Choose a reason for hiding this comment

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

We should add entries to the
allowedNames and describes sections of cli.ts.

Otherwise this looks good

lib/logger.ts Outdated
@@ -54,6 +54,8 @@ export class Logger {
static set(config: Config): void {
if (config.troubleshoot) {
Logger.logLevel = LogLevel.DEBUG;
} else if (config.logLevel) {
Logger.logLevel = (<any>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.

What is (<any>LogLevel) accomplishing here? I'm able to compile without it (that said, I'm not a typescript expert, so perhaps I am missing something).

Copy link
Contributor

Choose a reason for hiding this comment

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

NVM this is an error in [email protected] but not 2.0.10 (which we have pinned)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess you figured out but it is used to convert string to enum, found on SO.

Would you prefer a comment to make it easier to read or just remove it for now?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think i'm okay leaving it as is; unless others have strong opinions.

Copy link

Choose a reason for hiding this comment

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

We might try something like this for log levels :

let logLevel: 'ERROR'|'WARN'|'INFO'|'DEBUG'
logLevel = 'OLOLO' //compilation error here

@bcaudan bcaudan force-pushed the configure-log-level branch from 001158e to f3e2928 Compare March 9, 2017 19:30
@bcaudan
Copy link
Contributor Author

bcaudan commented Mar 9, 2017

I have updated cli.ts accordingly

Copy link
Contributor

@NickTomlin NickTomlin left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thanks!

@cnishina @seanmay any thoughts?

@NickTomlin
Copy link
Contributor

I was playing around with the typing for LogLevel a little more (using TS 2.1) and I think i've found a simplified version that has the benefit of explicitly stating the values for logLevel in code NickTomlin@3fe8606. This results in an exception in the logger if the value is not valid:

./bin/protractor example/conf.js --logLevel=NOT_VALID
/Users/ntomlin/workspace/protractor/built/logger.js:130
                throw new Error('Log level invalid or undefined');
                ^

Error: Log level invalid or undefined
    at Logger.log_ (/Users/ntomlin/workspace/protractor/built/logger.js:130:23)
    at Logger.debug (/Users/ntomlin/workspace/protractor/built/logger.js:86:14)
    at Object.initFn [as init] (/Users/ntomlin/workspace/protractor/built/launcher.js:98:12)

@bcaudan bcaudan force-pushed the configure-log-level branch 2 times, most recently from dc08766 to 576c2f5 Compare March 15, 2017 09:47
@bcaudan
Copy link
Contributor Author

bcaudan commented Mar 15, 2017

I have updated the PR with @NickTomlin and @Xotabu4 suggestions

@bcaudan
Copy link
Contributor Author

bcaudan commented Apr 18, 2017

How are we on this PR?

@NickTomlin
Copy link
Contributor

@seanmay mind taking a look at this when you have some free time?

@igniteram
Copy link
Contributor

can we merge this PR? It is a useful feature!

@qiyigg
Copy link
Contributor

qiyigg commented Nov 3, 2017

Could you please add a test for this change?

@alecmerdler
Copy link

We would also really like to see this merged.

@igniteram
Copy link
Contributor

@bcaudan If you get time can you please add some tests? This PR is pending from long time!
@alecmerdler Meanwhile you could use cliptor for configuring this log level, It basically wraps the same setting which is implemented in this PR.

@alecmerdler
Copy link

I've been using this hacky solution for now.

Also, I would be open to writing tests for this PR (or opening another with tests) if that would be okay with @bcaudan.

@qiyigg
Copy link
Contributor

qiyigg commented Jan 17, 2018

Sorry for the long delay.
I think this PR was pending for a long time and @alecmerdler or someone else, please feel free to create a new one for it.
As long as the new one is created, I will close this one, Thanks!

@alecmerdler
Copy link

@qiyigg This PR doesn't have any merge conflicts, why do we need to open a new one? I am glad to do it but would prefer to give @bcaudan the credit.

@bcaudan bcaudan force-pushed the configure-log-level branch from 576c2f5 to 50b5e26 Compare February 12, 2018 12:16
@bcaudan bcaudan force-pushed the configure-log-level branch from 50b5e26 to 3a61497 Compare February 12, 2018 12:47
@bcaudan
Copy link
Contributor Author

bcaudan commented Feb 12, 2018

@qiyigg I have added some unit tests for the Logger.
Let me know if you had other tests in mind.

circle ci tests exited with:

A command timed out during your tests

is it a known error? can you trigger a rebuild?

@qiyigg
Copy link
Contributor

qiyigg commented Feb 12, 2018

@bcaudan I already triggered a rebuild, let's see what happens.
The circleCI should be already fixed since last release.
Thanks for adding these tests. My understanding is it would be better to have a integration test, say, have a separate config file which sets loglevel there, and check it during test. But since it is a simple change, I am OK with current test.
I can merge the change as long as the circleCI is passed.

@qiyigg qiyigg merged commit cc2234c into angular:master Feb 12, 2018
qiyigg added a commit that referenced this pull request Feb 13, 2018
@bcaudan bcaudan deleted the configure-log-level branch February 13, 2018 08:41
@alecmerdler
Copy link

@qiyigg Will there be a new release soon with these changes?

@qiyigg
Copy link
Contributor

qiyigg commented Mar 27, 2018

@alecmerdler to be honest, I don't have enough bandwidth recently, I'll try to make it this week, but no guarantee.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants