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

Issue/62 custom access and error log handlers (against 0.9-stable) #71

Open
wants to merge 7 commits into
base: 0.9-stable
Choose a base branch
from

Conversation

robertmassaioli
Copy link

Note: This is the first of two pull requests. This is the first one and aims to backport my changes to 0.9-stable. The second one will port these changes to master.

I am trying to solve #62 in this pull request. It is my aim to be able to push out the access and error logs in a custom format: in my case, JSON. You can see an example of me testing this branch and doing that here:

My Reminders JSON log

You can see an example of me using this branch in the My Reminders code here: https://bitbucket.org/atlassianlabs/my-reminders/branch/issue/MR-7-json-logs-for-my-reminders#diff

I hope that you like these changes and are willing to accept them. I have spoken to @gregorycollins and he suggested that such a feature would be desirable. I am also open to suggestions on how to improve this PR but I can tell you that it works (via my manual testing) and lightly extends existing behaviour in its current form.

P.S. If you want to know why I want to output custom log line formats into JSON then the answer is simple: it is because that is a really nice way to pass the data into Logstash / Kibana so that I can easily monitor the services that I have written using the Snap framework. There are likely many many reasons too that various snap framework users would like to customise the log lines coming from their apps.

@robertmassaioli
Copy link
Author

If anybody was around to give some quick feedback that would be great. :) I'm halfway through having a branch ready (based on this one) that could be merged into master. Therefore if would be good to get a nod of approval on the general approach just to make sure I'm not spinning my wheels.

@robertmassaioli
Copy link
Author

And I have just done the work required to get this merged against master too: #72

@robertmassaioli robertmassaioli changed the title Issue/62 custom access and error log handlers Issue/62 custom access and error log handlers (against 0.9-stable) May 22, 2015
@robertmassaioli
Copy link
Author

@gregorycollins As we talked about, I think that this PR is done (against 0.9-stable) the (1.0 release is still up for discussion).

Therefore could we merge this in and then I'll do the other steps that you have asked me to do?


------------------------------------------------------------------------------
debugE :: (MonadIO m) => ByteString -> m ()
debugE s = debug $ "Server: " ++ (map w2c $ S.unpack s)

------------------------------------------------------------------------------
defaultAccessLogHandler :: AccessLogHandler
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Export this one too, in case users want to mix and match?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand, if you simply don't set anything in the config instance then won't this be the default. Do we need to export it if it is the result of the customer doing nothing? I thought that was the beauty of Config being an instance of Monoid.

That said I just wanted to be really sure that was what you wanted me to do and add it to the public api. I'm more than happy to do it if you say yes again. 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I meant that it should be exported from the module.

@gregorycollins
Copy link
Member

Sorry I meant 0.10! Meant to type .10 but fat fingered it.

@robertmassaioli
Copy link
Author

Oh, sweet. 😃 That makes much more sense! I'll get it done.

@robertmassaioli
Copy link
Author

Okay, version bumped @gregorycollins and I think that this can be merged whenever you are ready.

I'm going to update the snap-website code now.

@robertmassaioli
Copy link
Author

Linking this here: snapframework/snap-website#40

Okay:

  • ✅ Code ready to go and no comments left unanswered.
  • ✅ Version numbers have been appropriately updated.
  • ✅ snap-website release documentation for snap-server updated and in PR.
  • ✅ Changes seem to be good and testing shows that they work as intended.

I think that we are good to merge @gregorycollins so just let me know if there is anything more that I can do. Otherwise I'm excited to see this happen!

@robertmassaioli
Copy link
Author

Hi @gregorycollins, we never merged in this pull request at the time and it seemed to be a bad time to try and get this work in. However, I am starting to see a need for this functionality again and I would love to be able to merge it back in.

Do you remember what stopped us from merging this in all of those months ago? Either way I would like to resolve those issues, build it properly, and get it released.

Please let me know what I can do to help get my PR into that state. Cheers!

@galenhuntington
Copy link

Hi all! I recently needed log customization myself, and did so by just modifying my own copy of the code. This PR seems a pretty good general solution, well-designed and without introducing any compatibility issues. Is there a reason it's been languishing and can't just be merged?

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

Successfully merging this pull request may close these issues.

3 participants