-
Notifications
You must be signed in to change notification settings - Fork 517
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
Default to pretty-printed output if process.stdout.isTTY #13
Comments
How about attaching a formatter to a Logger stream? Or the (sub)Logger in general. var log = new Logger({
name: "amon",
streams: [
{
level: "info",
stream: process.stdout,
formatter: "pretty"
},
{
level: "error",
stream: "./error.log" // Uses default JSON formatter
}
]
} |
Getting closer. |
Anything new here? This is the only feature I'm missing to fully use bunyan. |
I have some work started on the 1.x branch, but it is a ways from being ready. I also have a looming deadline mid-December at work, so I probably won't get back to this until after then. |
👍 Yes, please! |
+1. I've created a minimal writable stream that prints out the level/message and am using that for the time being. (Maybe there is a better workaround?) |
Any updates on this? I've been using a simple shell script to save those keystrokes: #!/usr/bin/env sh
node . | bunyan -o short But I had some free time so I tried writing a stream to pipe the output through It should work if your main process is long running (web servers, etc) but isn't ideal for short running apps like cli tools. var spawn = require('child_process').spawn;
var through = require('through');
var path = require('path');
var fs = require('fs');
var prettyStream = function(args) {
args = args || ['-o', 'short'];
var bin = path.resolve(path.dirname(require.resolve('bunyan')), '..', 'bin', 'bunyan');
var stream = through(function write(data) {
this.queue(data);
}, function end () {
this.queue(null);
});
if(bin && fs.existsSync(bin)) {
var formatter = spawn(bin, ['-o', 'short'], {
stdio: [null, process.stdout, process.stderr]
});
stream.pipe(formatter.stdin);
}
return stream;
};
bunyan.createLogger({
name: 'test',
stream: process.stdout.isTTY ? prettyStream() : process.stdout,
level: 'info'
}); |
@jameswyse unfortunately I haven't had a chance yet :( I have a big release of work stuff in a couple weeks. I hope to get a chance for this ticket (among a few others) after that. |
Whatever happened to this? Bunyan would be perfect if this were implemented. Needing to pipe to bunyan is quite annoying. I would switch everything to bunyan if it were not for this one issue. |
+1 |
We have some command line utils which fetch JSON logs from the server, and I keep forgetting to pipe the result to bunyan. I wish something like this existed so we could (within the CLI client) check if output it to TTY and if so call bunyan.formatOutput(...) instead of just printing out the raw JSON. |
+1 |
+1 |
+1 looking forward for this feature. |
+1 |
This is the main thing that stops me from choosing |
@trentm Are you looking at this already or you still don't have time? |
+1 |
I neeeeeeed this! +1 |
After trying out this logger package, this is one of the first features I found myself wanting and is the only one that is missing at the moment. Any news on where this might be at? |
+1 any updates? |
Nothing after 4 years? |
To anyone still looking, this works well: https://github.com/mrrama/node-bunyan-prettystream import bunyan from 'bunyan';
import PrettyStream from 'bunyan-prettystream';
const stream = new PrettyStream();
stream.pipe(process.stdout);
const logger = bunyan.createLogger({
name: 'npm-search',
streams: [{
stream,
}],
}); |
Or even this: https://github.com/benbria/bunyan-debug-stream seems to work better |
|
Now that bunyan-cli doesn't process ctrl+c/SIGINT anymore (in patch release!) this is even more important. |
I just send this to a nodejs stream and manually console.log (assuming you have not overwritten console.log behavior)
|
Are there any updates to this? Would also like to use this in our CLI tool! |
It's pretty common in development to do a lot of
node server.js
and watch the output. Piping that to bunyan is a bit annoying.It should default to doing the pretty stuff if process.stdout.isTTY === true.
The text was updated successfully, but these errors were encountered: