Skip to content

Added setting python.logging.level which carries the logging level value the extension will log at - #11698

Merged
Kartik Raj (karrtikr) merged 9 commits into
microsoft:logging-changes-and-drop-old-debuggerfrom
karrtikr:addloggingsetting
May 14, 2020
Merged

Added setting python.logging.level which carries the logging level value the extension will log at#11698
Kartik Raj (karrtikr) merged 9 commits into
microsoft:logging-changes-and-drop-old-debuggerfrom
karrtikr:addloggingsetting

Conversation

@karrtikr

@karrtikr Kartik Raj (karrtikr) commented May 8, 2020

Copy link
Copy Markdown

For #11699

This PR is based on #11695

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR).
  • Title summarizes what is changing.
  • Has a news entry file (remember to thank yourself!).
  • Appropriate comments and documentation strings in the code.
  • Has sufficient logging.
  • Has telemetry for enhancements.
  • Unit tests & system/integration tests are added/updated.
  • Test plan is updated as appropriate.
  • package-lock.json has been regenerated by running npm install (if dependencies have changed).
  • The wiki is updated with any design decisions/details.

@karrtikr
Kartik Raj (karrtikr) marked this pull request as ready for review May 8, 2020 15:28
@karrtikr
Kartik Raj (karrtikr) marked this pull request as ready for review May 8, 2020 15:28
@codecov-io

Codecov (codecov-io) commented May 8, 2020

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (logging-changes-and-drop-old-debugger@be9f3ce). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@                           Coverage Diff                            @@
##             logging-changes-and-drop-old-debugger   #11698   +/-   ##
========================================================================
  Coverage                                         ?   60.67%           
========================================================================
  Files                                            ?      629           
  Lines                                            ?    34040           
  Branches                                         ?     4798           
========================================================================
  Hits                                             ?    20655           
  Misses                                           ?    12375           
  Partials                                         ?     1010           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update be9f3ce...0c9c301. Read the comment docs.

@ericsnowcurrently Eric Snow (ericsnowcurrently) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

How does this PR relate to #11695? It seems like there is some overlap. It isn't clear why this PR needs to be based on the other.

Comment thread src/client/logging/_global.ts Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A few more comments.

Comment thread src/client/logging/logger.ts Outdated
Comment thread src/client/common/types.ts
Comment thread src/client/common/configSettings.ts Outdated
Comment thread src/client/logging/logger.ts Outdated
Comment thread src/client/common/types.ts
@karrtikr
Kartik Raj (karrtikr) force-pushed the addloggingsetting branch 2 times, most recently from 7a5dac4 to b388197 Compare May 12, 2020 14:56

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This PR look alright to me, but I have no context on what would make sense or not, I'll let Eric Snow (@ericsnowcurrently) be the judge of that 🙂

Comment thread src/client/common/configSettings.ts Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for making those changes. It's looking good. I've left some minor comments, with a number of them repeating the same recommendation regarding "Off". So I think this is close. Thanks again!

Comment thread src/client/common/configSettings.ts Outdated
Comment thread src/client/common/configSettings.ts Outdated
Comment thread src/client/extensionActivation.ts Outdated
Comment thread src/client/logging/formatters.ts Outdated
Comment thread src/client/logging/levels.ts Outdated
Comment thread src/client/logging/levels.ts Outdated
Comment thread src/client/logging/levels.ts Outdated
Comment thread src/client/logging/logger.ts
Comment thread src/client/logging/transports.ts Outdated
Comment thread src/client/logging/_global.ts Outdated
@karrtikr

Kartik Raj (karrtikr) commented May 13, 2020

Copy link
Copy Markdown
Author

Eric Snow (@ericsnowcurrently) Having Off in LogLevel implies that we've to Off everywhere. For instance,

export function resolveLevelName(
    level: LogLevel,
    // Default to configLevels.
    levels?: winston.config.AbstractConfigSetLevels
): string | undefined {
    if (levels === undefined) {
        return getLevelName(level);
    } else if (levels === configLevels) {
        return getLevelName(level);
    } else if (levels === winston.config.npm.levels) {
        return npmLogLevelMap[level];
    } else {
        return undefined;
    }
}

Here level can be LogLevel.Off, so npmLogLevelMap should also have LogLevel.Off as key, which was the reason I had to put a dummy "off" everywhere.
A solution I can see is to remove Off from LogLevel and use undefined instead.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

At this point I only have one thing that I think should be done slightly differently: use a different sentinel value (than undefined) in the PythonSettings to say "disable logging".

Otherwise the changes look good. Thanks for your patience. FYI, the other two comments are just minor changes (formatting and expanding a comment).

Comment thread src/client/logging/logger.ts
Comment thread src/client/logging/_global.ts Outdated
Comment thread src/client/common/types.ts Outdated
@ericsnowcurrently

Copy link
Copy Markdown

Eric Snow (@ericsnowcurrently) Having Off in LogLevel implies that we've to Off everywhere.
[snip]
Here level can be LogLevel.Off, so npmLogLevelMap should also have LogLevel.Off as key, which was the reason I had to put a dummy "off" everywhere.
A solution I can see is to remove Off from LogLevel and use undefined instead.

I'm fine with not adding LogLevel.Off. I think you're right. However, I think we need a different sentinel value to mean "disable logging". undefined implies "not set", which isn't right. As I suggested in my last review, better alternatives would be null, "off", or a dedicated value (like const DisableLogging = {};). What do you think?

(Also, it may make sense to have a separate setting to disable logging, rather than overloading "python.logging.level".)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

Thanks for working it out. 😄

@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@karrtikr
Kartik Raj (karrtikr) merged commit 2db900c into microsoft:logging-changes-and-drop-old-debugger May 14, 2020
@karrtikr
Kartik Raj (karrtikr) deleted the addloggingsetting branch May 14, 2020 22:53
Karthik Nadig (karthiknadig) pushed a commit to karthiknadig/vscode-python that referenced this pull request Jun 17, 2020
…value the extension will log at (microsoft#11698)

* Added setting

* Code reviews

* Fix unit tests

* Code reviews

* Put config.level back

* Added commnet

* Code review

* More code reviews

* Fix tests
Eric Snow (ericsnowcurrently) pushed a commit to ericsnowcurrently/vscode-python that referenced this pull request Jun 18, 2020
…value the extension will log at (microsoft#11698)

* Added setting

* Code reviews

* Fix unit tests

* Code reviews

* Put config.level back

* Added commnet

* Code review

* More code reviews

* Fix tests
Eric Snow (ericsnowcurrently) pushed a commit to ericsnowcurrently/vscode-python that referenced this pull request Jun 18, 2020
…value the extension will log at (microsoft#11698)

* Added setting

* Code reviews

* Fix unit tests

* Code reviews

* Put config.level back

* Added commnet

* Code review

* More code reviews

* Fix tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants