-
-
Notifications
You must be signed in to change notification settings - Fork 535
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
Deprecate morgan.compile #223
Comments
I think we need to get feedback from users before removing it, as this was a specific feature request by the module users (see #69 for instance). |
You wouldn't, of course. That is not the purpose of exporting the compile function. |
Yes, I definitely agree on this. Of course I cannot recall anyone actually having an issue with this, and so I'm not sure if it makes sense to change this without any users actually asking for in. Conversely, it is there for performance concerns (which may or may not be founded any longer) since the typical arrangement of this module is to be involved in every request, making a performance here a top priority. |
So this is why both are allowed: different people find different priorities. Personally many folks like myself keep the log format in configuration, which is not code and cannot contain functions. Having a token syntax is necessary for this use case. |
Definitely! Any proposals for changing this would have to be backed up by perf benchmarks compared to the existing implementation |
great point! I didn't think about keeping these strings in a configuration file |
compile
is a way to create a custom format function that can be passed tomorgan
. There's already a way to write a custom formatter function usingmorgan.format
. Anything I can do withcompile
, I can do with a customformat
function.In addition, the
compile
function uses a method some would consider unsafe. I think if we can find a way to not dynamically create functions and call them, that's a win.Given that
compile
returns a custom format function that I can then pass tomorgan
, why wouldn't I write a custom format function directly instead of usingcompile
?with compile:
with custom formatter:
The
compile
function and token syntax does reduce the amount of code I have to write myself but I have to learn a new syntax and understanding how thecompile
function works could be confusing for newcomers to the library. Using onlyformat
functions keeps things easier to reason about and maintain in the future.The text was updated successfully, but these errors were encountered: