From 0c0e3981278a0d7a21cf40861b58b7246618411d Mon Sep 17 00:00:00 2001 From: Ryan Hinchey Date: Thu, 9 Apr 2020 21:10:12 -0400 Subject: [PATCH] move formats one level under the morgan object --- index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index b33c4f2..95e504b 100644 --- a/index.js +++ b/index.js @@ -145,6 +145,8 @@ function morgan (format, options) { } } +morgan.formats = {} + /** * Apache combined log format. */ @@ -162,7 +164,7 @@ morgan.format('common', ':remote-addr - :remote-user [:date[clf]] ":method :url */ morgan.format('default', ':remote-addr - :remote-user [:date] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent"') -deprecate.property(morgan, 'default', 'default format: use combined format') +deprecate.property(morgan.formats, 'default', 'default format: use combined format') /** * Short format. @@ -452,7 +454,7 @@ function createBufferStream (stream, interval) { */ function format (name, fmt) { - morgan[name] = fmt + morgan.formats[name] = fmt return this } @@ -466,7 +468,7 @@ function format (name, fmt) { function getFormatFunction (name) { // lookup format - var fmt = morgan[name] || name || morgan.default + var fmt = morgan.formats[name] || name || morgan.formats.default // return compiled format return typeof fmt !== 'function'