Skip to content

Bug: Logger doesn't log to vscode debug terminal #926

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

Closed
Stefan-WW opened this issue May 31, 2022 · 4 comments
Closed

Bug: Logger doesn't log to vscode debug terminal #926

Stefan-WW opened this issue May 31, 2022 · 4 comments
Assignees
Labels
logger This item relates to the Logger Utility not-a-bug New and existing bug reports incorrectly submitted as bug rejected This is something we will not be working on. At least, not in the measurable future

Comments

@Stefan-WW
Copy link

Hello,

While development, i run my code locally in vscode.
But the lambda-powertools-logger doesn't log to the vscode debug terminal.

The following Code shows the Problem.

`

        const logger = new Logger({ serviceName: 'MyService', logLevel: 'DEBUG' });
        logger.debug('debug');
        logger.warn('warn');
        logger.error('error');
        logger.info('info');
        console.log('real logging');
        console.warn('real warning');
        console.info('real info');`

If i use console.log etc the Loggings are shown in the vscode debug terminal.
But the logger from the powertools are not shown.

if i would add a small hack above:
//@ts-ignore logger.console = console;

Then the loggings are shown in the debug terminal.

Expected Behavior

The Logs which are written, should be also shown in the vscode debug terminal.

Environment

  • Powertools version used: 0.9.1
  • Packaging format (Layers, npm): npm
  • AWS Lambda function runtime: nodejs
@Stefan-WW Stefan-WW added bug Something isn't working triage This item has not been triaged by a maintainer, please wait labels May 31, 2022
@dreamorosi
Copy link
Contributor

@StefanVolkmer-WW thanks for opening the issue.

Could you please share your .vscode/launch.json or alternative clarify how you are executing the function? Would like to try to reproduce the issue.

@dreamorosi dreamorosi added the logger This item relates to the Logger Utility label May 31, 2022
@StefanV85
Copy link

Hello @dreamorosi
The Launch Config is the following:
{ "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "name": "launch", "program": "${workspaceRoot}/index.js", "preLaunchTask": "TypeScript->JavaScript" } ] }

You can reproduce it with a Standard Config.
I created a Hello World Project:
https://github.com/StefanV85/LambdaPowerToolsLoggerExample

Just Clone the Repository,
run npm install
Run the Launch Config.

@dreamorosi
Copy link
Contributor

Thanks for the config & sample repository, it's been really helpful.

I've looked into it and was able to reproduce the issue but I believe this is not a bug of Powertools Logger.

As you can see in this part of the Logger implementation, we output logs directly to process.stdout & process.stderr rather than simply using console.log - this change was made in #748 to have a cleaner output on AWS Lambda, which is the primary execution environment that we are targeting at the moment (see our project tenets here).

With that said, while looking at your repo I noticed that also something like process.stdout.write('something') was not showing up in the VSCode debug console. I then searched for existing issues on the VSCode repo and found this one microsoft/vscode#19750.

In one of the comments, it is suggested to add an additional setting ("outputCapture": "std") to the Launch config like so:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "launch",
            "program": "${workspaceRoot}/index.js",
            "preLaunchTask": "TypeScript->JavaScript",
            "outputCapture": "std"
        }
    ]
}

See screenshot below that shows the new config, running your code, and with all the log outputs.
Screenshot 2022-06-01 at 10 58 20

I'm going to be closing the issue and remove the bug label.

@dreamorosi dreamorosi removed bug Something isn't working triage This item has not been triaged by a maintainer, please wait labels Jun 1, 2022
@dreamorosi dreamorosi self-assigned this Jun 1, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jun 1, 2022

⚠️ COMMENT VISIBILITY WARNING ⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@dreamorosi dreamorosi changed the title Bug (logger): Logger doesn't log to vscode debug terminal Bug: Logger doesn't log to vscode debug terminal Nov 14, 2022
@dreamorosi dreamorosi added rejected This is something we will not be working on. At least, not in the measurable future not-a-bug New and existing bug reports incorrectly submitted as bug labels Nov 14, 2022
@dreamorosi dreamorosi moved this from Shipped to Closed in AWS Lambda Powertools for TypeScript Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logger This item relates to the Logger Utility not-a-bug New and existing bug reports incorrectly submitted as bug rejected This is something we will not be working on. At least, not in the measurable future
Projects
None yet
Development

No branches or pull requests

3 participants