-
Notifications
You must be signed in to change notification settings - Fork 533
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
changed default stream to <<stdout+'\n'>> #17
Conversation
changed to code so that the default stream is stdout with a line break at the end. Before this change the default stream was stdout and the line break was _hard coded_ during the write operation. This prevented using a custom streams which do not require or expect line breaks (e.g., winston transports)
Thanks! This is a good idea, but it is super breaking and will just have to wait for the next major. People are already passing in their own custom streams and expecting the newline to be at the end, which this removes. |
if this is too much of a breaking change I have another suggestion:
|
I agree and was already planning that :)
i think it should still be options.stream--stream is a universal interface in node.js and if you call it write, people will want to do |
Having a direct write option is not very important, though I think is is reasonable to support both a direct function and an object by doing something like:
I any case, I think it is important to rename how about |
So after thinking on it, I'm going to close this. The reason is that this module creates text lines and streams them as a text stream. It sounds like you just want a stream of lines, rather than a stream of text. If you want your stream to be split on lines, simply pass in a stream that uses something like https://www.npmjs.org/package/split |
Example: var morgan = require('morgan')
var split = require('split')
var myStream = ... // your stream you want to get line events to
app.use(morgan({
stream: split().pipe(myStream)
})) |
FWIW I don't agree - the are use cases both ways var morgan = require('morgan')
var split = require('split')
var winston = require("winston");
var winstonStream = require("winston-stream");
var log = winstonStream(winston, "info");
app.use(morgan({
stream: split().pipe(log)
})) |
OK, but the reverse is true for all the people who log to a file stream, then. We want no boilerplate for this pattern: var fs= require('fs')
var morgan = require('morgan')
app.use(morgan({
stream: fs.createWriteStream('access.log', {flags: 'a'})
})) |
Also, your example it not useful, because the var morgan = require('morgan')
var winston = require("winston");
var winstonStream = require("winston-stream");
var log = winstonStream(winston, "info");
app.use(morgan({
stream: log
})) |
changed to code so that the default stream is stdout with a line break at the end.
Before this change the default stream was stdout and the line break was hard-coded during the write operation.
This prevented using a custom streams which do not require or expect line breaks (e.g., winston transports)