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

Replace root logger. #11

Open
c-bata opened this issue May 18, 2016 · 1 comment
Open

Replace root logger. #11

c-bata opened this issue May 18, 2016 · 1 comment

Comments

@c-bata
Copy link

c-bata commented May 18, 2016

This project is interesting to me.

I think python's library should not use root logger like:

import logging
 logging.warn('this is a warning')

refs: http://pieces.openpolitics.com/2012/04/python-logging-best-practices/

Would you replace root logger like:

from logging import getLogger

logger = getLogger(__name__)
logger.warn('this is a warning')
@akubera
Copy link
Member

akubera commented May 18, 2016

Thanks for the link! I haven't done a whole lot with the logger module before.

Are you talking specifically about the Logger middleware class? I think I use getLogger for most of the logging in the project.

In your opinion, do do you think that a new log should be created for each incoming connection:

def __call__(self, req, res):
    req.log = getLogger('req')

or as I have it now, where the Logger middleware attaches itself to the request, and is used as a proxy for the internal logger?

def __call__(self, req, res):
    req.log = self

Also, I'm open for suggestions on best ways to format the log prefix, or at least allowing the user to chose the format.

I'll probably visit this after I figure out the event system, the goal being the ability to log the response status code and content size after being sent.

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

No branches or pull requests

2 participants