Skip to content

Standard output stream#109

Merged
bd82 merged 1 commit intoSAP:masterfrom
saggir:standard-output
Jul 29, 2020
Merged

Standard output stream#109
bd82 merged 1 commit intoSAP:masterfrom
saggir:standard-output

Conversation

@saggir
Copy link
Copy Markdown
Contributor

@saggir saggir commented Jul 23, 2020

Adding support for console stream messages.
When enabling the Console options, messages that are printed using this library will be logged to the console stream (e.g. stdout/stderr in Linux or Debug Console in VSCode)

The Console stream is optional, default=false

You can enable it by setting: "logConsole: true" in the constructor options

This feature can be useful when debugging your extension.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jul 23, 2020

CLA assistant check
All committers have signed the CLA.

@bd82 bd82 self-requested a review July 23, 2020 08:10
} = require("./settings");
const { registerCommands } = require("./commands");
const { listenToLogSettingsChanges } = require("./settings-changes-handler");
const { callLibraryAndPassLogger } = require("./passing-logger-to-library");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

don't remove part of this example

Comment thread examples/extension/lib/extension.js
Comment thread examples/extension/lib/extension.js
},
"scripts": {},
"dependencies": {
"@vscode-logging/library-example": "^0.1.2",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

don't remove parts of this example

Comment thread packages/logger/README.md Outdated
logOutputChannel: logOutputChannel, // OutputChannel for the logger
sourceLocationTracking: false
sourceLocationTracking: false,
standardOutput: false //define if messages should be logged to the standard output stream
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  1. missing whitespace between // and define
  2. be consistent with previous property name:
    • logOutputChannel --> logStandardOut | logStdout

Comment thread packages/logger/api.d.ts Outdated
* Warn, Info, Debug and Trace are printed to the standard output console
* Default = false
*/
standardOutput?: boolean;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See comment above regarding the property name

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reading this comment it makes me thing the property name should maybe be
logConsole or logToConsole

Because your description uses the word console multiple times.
and console.error does not go to stdoutput stream

Comment thread packages/logger/lib/api.js Outdated
@@ -1,5 +1,5 @@
const { has } = require("lodash");
const { createLogger } = require("winston");
const winston = require("winston");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why was this imported changed?

Comment thread packages/logger/lib/api.js Outdated
*/
const transports = [];

if (opts.standardOutput) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See the check above for "Logger must have at least one logging target defined, either logOutputChannel or logPath." you should update that as well

Comment thread packages/logger/lib/transports/standard-output.js
Comment thread packages/logger/lib/transports/standard-output.js Outdated
Comment thread packages/logger/lib/transports/standard-output.js Outdated
@@ -0,0 +1,95 @@
const { VSCodeStub } = require("./stubs/vscode-stub");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why does this test need a vscode stub? can we disable the outputChannel?

Comment thread packages/logger/test/standard-output-spec.js Outdated
let getExtensionLogger;
beforeEach(function() {
vsCodeStub = new VSCodeStub();
const mainModuleStubbed = proxyquire("../lib/api.js", {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you won't need the proxyQuire either if you remove the vscodestub

Comment thread packages/logger/test/standard-output-spec.js
Comment thread packages/logger/test/standard-output-spec.js Outdated
Comment thread packages/logger/test/standard-output-spec.js Outdated
@saggir saggir requested a review from bd82 July 26, 2020 08:05
Comment thread examples/extension/README.md Outdated
@@ -1,4 +1,4 @@
# @vscode-logging Extension Example
# @vscode-logging Extension Example
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

adding whitespace here messes up the file rendering

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

image

Comment thread packages/logger/api.d.ts Outdated
* Warn, Info, Debug and Trace are printed to the standard output console
* Default = false
*/
logStandardOutput?: boolean;
Copy link
Copy Markdown
Member

@bd82 bd82 Jul 27, 2020

Choose a reason for hiding this comment

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

Naming and description of the property in this public API could be improved.

Perhaps just expose the implementation details and call it logConsole or consoleLog?

it("should not log to standard output when logStandardOutput is false", function() {
const extLogger = getExtensionLogger({
extName: "MyExtName",
logOutputChannel: vsCodeStub.OutputChannel,
Copy link
Copy Markdown
Member

@bd82 bd82 Jul 27, 2020

Choose a reason for hiding this comment

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

Using a VSCode stub may be more complicated then using a File logger in this case. (logPath)

Copy link
Copy Markdown
Member

@bd82 bd82 left a comment

Choose a reason for hiding this comment

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

Some earlier comments were not addressed.
The main new comment is about the name of the new API.

I will not have time to review it again, proceed as you believe is best.

@bd82
Copy link
Copy Markdown
Member

bd82 commented Jul 29, 2020

You did not follow the contribution guidelines.

The commit message format is not by the convention, This means that the automatic changelog generation would
not work correctly.

@bd82
Copy link
Copy Markdown
Member

bd82 commented Jul 29, 2020

How were you able to bypass the commit message linter?

Did you do git commit --no-verify?

Comment thread examples/extension/lib/extension.js Outdated
logOutputChannel: logOutputChannel,
sourceLocationTracking: sourceLocationTrackingSettings
sourceLocationTracking: sourceLocationTrackingSettings,
logConsol: true
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

logConsol is a typo missing e (console)

Comment thread packages/logger/README.md
logOutputChannel: logOutputChannel, // OutputChannel for the logger
sourceLocationTracking: false
sourceLocationTracking: false,
logConsol: false // define if messages should be logged to the consol
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

logConsol is a typo missing e (console)

Comment thread packages/logger/api.d.ts Outdated
* Warn, Info, Debug and Trace are printed to the standard output console
* Default = false
*/
logConsol?: boolean;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

logConsol is a typo missing e (console)

Comment thread packages/logger/lib/api.js Outdated
) {
throw Error(
"Logger must have at least one logging target defined, either logOutputChannel or logPath."
"Logger must have at least one logging target defined, it should includes one (or more) of these options: logOutputChannel, logPath and logConsol"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

logConsol is a typo missing e (console)

Comment thread packages/logger/lib/api.js Outdated
*/
const transports = [];

if (opts.logConsol) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

logConsol is a typo missing e (console)

Comment thread packages/logger/lib/api.js Outdated
outChannel: opts.logOutputChannel,
sourceLocationTracking: opts.sourceLocationTracking
sourceLocationTracking: opts.sourceLocationTracking,
consolOutput: opts.logConsol
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

consoleOutput

@bd82
Copy link
Copy Markdown
Member

bd82 commented Jul 29, 2020

There is a general typo consol --> console
I marked some of the places but there are more.

@saggir saggir force-pushed the standard-output branch from ac9ee25 to d221307 Compare July 29, 2020 08:54
@saggir saggir force-pushed the standard-output branch from b81f494 to 5d760cf Compare July 29, 2020 09:16
@bd82 bd82 merged commit fcfae3a into SAP:master Jul 29, 2020
bd82 pushed a commit that referenced this pull request Jul 29, 2020
alex-gilin added a commit that referenced this pull request Apr 15, 2026
Resolves Dependabot alerts via pnpm overrides for transitive dependencies.

Packages updated:
axios → 1.15.0 (#170)
handlebars → 4.7.9 (#163, #162, #159, #158, #157, #156, #155, #153)
tar → 7.5.13 (#147, #146, #128, #124, #120, #118)
brace-expansion@2.x → 2.0.3 (#161, #154)
js-yaml → 4.1.1 (#111)
micromatch → 4.0.8 (#91)
nanoid → 5.1.7 (#96)
yaml → 2.8.3 (#150)
diff → 5.2.2 (#119)
tmp → 0.2.5 (#109)
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.

3 participants