-
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
Setting stream to process.stdout causes TypeError: s.stream.write is not a function #332
Comments
It looks like you just have a configuration issue. So, I think what you want is this: var bunyan = require('bunyan');
var log = bunyan.createLogger({name: 'MAIN',
streams: [
{
level: 'info',
stream: process.stdout
},
{
level: 'warn',
stream: process.stdout
},
{
level: 'error',
stream: process.stdout
}
]}); |
@msealand thanks for answering I think I'll leave this ticket open to have Bunyan emit a clearer warning when that stream is first added... rather than obtusely error out later when writing the first record. |
@trentm We use a YAML config to generate configs for various loggers throughout our application. Because of this we had strings for We extended bunyan to support strings for these two streams, but we didn't like doing string checks. We ended up adding a new I could make a PR for strict checks on |
@Khez Yes, that has been discussed before. Here is a relevant other issue: #153 I've shied away from having Bunyan have a way to "spell" I lean toward more fully specing a "bunyan config from config" (including things like specifying serializers to use, etc.), very likely as a separate module. If that module got popular, I'd consider merging it in (if that author wanted to, of course). @Khez thanks for the PR offer, I think #335 from @michaelnisi will be that. |
@michaelnisi This looks like an ok thing to add, we actually have a very similar check (amongst others) Unfortunately this by itself does not fix the string Also made a comment on #355. Keep up the good work. 👍 |
I find crashing early and loudly often the best choice. With #355 @vrghost242 would get: assert.js:86
throw new assert.AssertionError({
^
AssertionError: "stream" stream is not writable: 'process.stdout'
at Logger.addStream (/Users/michael/workspace/node-bunyan/lib/bunyan.js:579:16)
at /Users/michael/workspace/node-bunyan/lib/bunyan.js:469:18
at Array.forEach (native)
at new Logger (/Users/michael/workspace/node-bunyan/lib/bunyan.js:468:25)
at Function.createLogger (/Users/michael/workspace/node-bunyan/lib/bunyan.js:1501:12)
at Object.<anonymous> (/Users/michael/workspace/node-bunyan/t.js:2:18)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12) The error message still needs some work, I guess. |
Well, I have the error message but how to finally make it work with a config file in JSON format ? I am going to give up using "stream":process.stdout |
Same problem |
So thought I would test this logger as it seems really good.
Thought I would create the logger with three levels to start with, so set it us as follows:
However, if I start the application with this code I get:
I also get a empty file called stdout.process
However, id I remove "streams"
I get the correct output to the terminal.
Not certain if this is key, but I am on a mac OSX develolpment machine
The text was updated successfully, but these errors were encountered: