fixes #7469 uncaughtException: stream.write is not a function

This commit is contained in:
Yaojian
2016-01-04 12:13:39 +08:00
parent fe563dff34
commit 4566a913a3
2 changed files with 12 additions and 3 deletions
+4 -2
View File
@@ -23,7 +23,9 @@ morgan('combined', {
buffer: true,
immediate: true,
skip: function (req, res) { return res.statusCode < 400 },
stream: (str: string) => {
console.log(str);
stream: {
write: (str: string) => {
console.log(str);
}
}
});
+8 -1
View File
@@ -12,6 +12,13 @@ declare module "morgan" {
export function token<T>(name: string, callback: (req: express.Request, res: express.Response) => T): express.RequestHandler;
export interface StreamOptions {
/**
* Output stream for writing log lines
*/
write: (str: string) => void;
}
/***
* Morgan accepts these properties in the options object.
*/
@@ -36,7 +43,7 @@ declare module "morgan" {
* Output stream for writing log lines, defaults to process.stdout.
* @param str
*/
stream?: (str: string) => void;
stream?: StreamOptions;
}
}