Skip to content
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

Is there a way to get the formatted output string inside the format function? #61

Closed
JimtotheB opened this issue May 6, 2015 · 4 comments
Assignees
Labels

Comments

@JimtotheB
Copy link

Im looking for a way to get the formatted string that morgan would otherwise send to the console, so I can pass it and an object representing the data to my logger. Currently I am just building the object with tokens['token'] and using that object to build up a string to output, but it is rather ugly and hard to match the format that morgan outputs on its own.

@dougwilson dougwilson changed the title [Question] Is there a way to get the formatted output string inside the format function? Is there a way to get the formatted output string inside the format function? May 6, 2015
@dougwilson dougwilson self-assigned this May 6, 2015
@dougwilson
Copy link
Contributor

I'm not 100% sure what the question is, but based on https://github.com/PaperElectron/Pomegranate/blob/master/lib/Middleware.js#L92 , #24 may help you. Let me know if it doesn't and can you provide an example of what you're trying to do?

@dougwilson
Copy link
Contributor

Nevermind on my above response; I didn't read down in your code. Let me see what I can come up with.

@JimtotheB
Copy link
Author

Sorry, I didn't think to just link the code in question. I was currently messing around with creating a new instance of morgan inside the format function and passing in a fake next(), but that doesn't solve the problem because it still just writes to stdout. So I figured I would ask here in case there is a simple answer.

@dougwilson
Copy link
Contributor

Closing, as the new morgan.compile should provide the necessary hook (and only requires a single eval at script start up, to boot). Example is over at the PR: #62 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants