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

Custom logging using e.g. katip/monad-logger #137

Open
mcfilib opened this issue Dec 13, 2017 · 4 comments
Open

Custom logging using e.g. katip/monad-logger #137

mcfilib opened this issue Dec 13, 2017 · 4 comments

Comments

@mcfilib
Copy link

mcfilib commented Dec 13, 2017

Hey folks, thanks for writing Spock!

This might not be the place for this request but I was wondering if you could perhaps add some advice to the documentation about how Spock users should go about adding logging to a Spock application. I know there are things like wai-extras that have a wai middleware for logging requests but, at least in the applications I work on, I'd also like to do some custom logging.

Specifically, I'm interested in how I should go about integrating with common libraries like monad-logger or katip but I'd appreciate any general advice you have.

@mcfilib
Copy link
Author

mcfilib commented Dec 13, 2017

I've added a repo with a minimal Spock app here on the offhand that someone has already done this in the past 😄

https://github.com/filib/spock-katip-example/blob/master/app/Main.hs

@agrafix
Copy link
Owner

agrafix commented Dec 14, 2017

I think the quickest way to achieve this is to add a logging interface to either:

  • add a logging interface data type to your st param which you can get via getState. Write some combinators to wrap this neatly.
  • use a logging solution that uses a global logger like simple-logger
  • send a PR to support logging within Spock :-)

@mcfilib
Copy link
Author

mcfilib commented Dec 16, 2017

I had to get things up and running quickly and simple-logger was just the ticket. Do you think that this would make a good Spock tutorial or would you prefer it be done on e.g. a personal blog post instead?

@agrafix
Copy link
Owner

agrafix commented Dec 17, 2017

A writeup on the Spock blog would also work for me.

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

No branches or pull requests

2 participants