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

Inconsistent behaviour on Windows with PowerShell #699

Open
TeamDman opened this issue Jul 27, 2022 · 0 comments
Open

Inconsistent behaviour on Windows with PowerShell #699

TeamDman opened this issue Jul 27, 2022 · 0 comments

Comments

@TeamDman
Copy link

TeamDman commented Jul 27, 2022

Problem

The non-cmd bin file works to format log entries from a piped node process, unless that process is running an http server.

Versions

node: v18.6.0
bunyan: "^1.8.15"
typescript: "^4.7.4"

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.5
PSEdition                      Core
GitCommitId                    7.2.5
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Demo

asd 3.js

const bunyan = require("bunyan");
const http = require("http");
const log = bunyan.createLogger({name: "beans"});

log.info("Starting");
http.createServer(undefined).listen(8080);
log.info("howdy");

Desired, but not working

PS> node '.\asd 3.js' | .\node_modules\.bin\bunyan
<nothing>

No formatting

PS> node '.\asd 3.js'                             
{"name":"beans","hostname":"Teamy-Desktop","pid":1280,"level":30,"msg":"Starting","time":"2022-07-27T02:56:24.297Z","v":0}
{"name":"beans","hostname":"Teamy-Desktop","pid":1280,"level":30,"msg":"howdy","time":"2022-07-27T02:56:24.301Z","v":0}

Works

PS> node '.\asd 3.js' | .\node_modules\.bin\bunyan.cmd
[2022-07-27T02:56:48.222Z]  INFO: beans/3192 on Teamy-Desktop: Starting
[2022-07-27T02:56:48.226Z]  INFO: beans/3192 on Teamy-Desktop: howdy

It took me longer than it should have to realize there was a .cmd version of the bin file, rather than some weird magical extension behaviour with powershell causing it to work.

asd 2.js

const bunyan = require("bunyan");

const log = bunyan.createLogger({ name: "radica backend", level: "debug", stream: process.stdout });

async function main() {
    log.info("howdy");
}
main();

Works without using the .cmd

PS> node '.\asd 2.js' | .\node_modules\.bin\bunyan
[2022-07-27T03:01:34.528Z]  INFO: radica backend/17224 on Teamy-Desktop: howdy
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

No branches or pull requests

1 participant