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

aiocache causing double logging in sanic #302

Closed
keattang opened this issue Jul 12, 2017 · 4 comments
Closed

aiocache causing double logging in sanic #302

keattang opened this issue Jul 12, 2017 · 4 comments

Comments

@keattang
Copy link

It appears that importing aiocache into a sanic app causes the sanic logs and print statements to be sent to stdout twice. My app looks like this:

from sanic import Sanic
from aiocache import caches

app = Sanic(__name__)

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8080, workers=4, debug=True)

And the logs on start up look like this:

2017-07-12 06:08:17 - (sanic)[DEBUG]: 
                 ▄▄▄▄▄
        ▀▀▀██████▄▄▄       _______________
      ▄▄▄▄▄  █████████▄  /                 \
     ▀▀▀▀█████▌ ▀▐▄ ▀▐█ |   Gotta go fast!  |
   ▀▀█████▄▄ ▀██████▄██ | _________________/
   ▀▄▄▄▄▄  ▀▀█▄▀█════█▀ |/
        ▀▀▀▄  ▀▀███ ▀       ▄▄
     ▄███▀▀██▄████████▄ ▄▀▀▀▀▀▀█▌
   ██▀▄▄▄██▀▄███▀ ▀▀████      ▄██
▄▀▀▀▄██▄▀▀▌████▒▒▒▒▒▒███     ▌▄▄▀
▌    ▐▀████▐███▒▒▒▒▒▐██▌
▀▄▄▄▄▀   ▀▀████▒▒▒▒▄██▀
          ▀▀█████████▀
        ▄▄██▀██████▀█
      ▄██▀     ▀▀▀  █
     ▄█             ▐▌
 ▄▄▄▄█▌              ▀█▄▄▄▄▀▀▄
▌     ▐                ▀▀▄▄▄▀
 ▀▀▄▄▀

2017-07-12 06:08:17,488 DEBUG sanic(691) | 
                 ▄▄▄▄▄
        ▀▀▀██████▄▄▄       _______________
      ▄▄▄▄▄  █████████▄  /                 \
     ▀▀▀▀█████▌ ▀▐▄ ▀▐█ |   Gotta go fast!  |
   ▀▀█████▄▄ ▀██████▄██ | _________________/
   ▀▄▄▄▄▄  ▀▀█▄▀█════█▀ |/
        ▀▀▀▄  ▀▀███ ▀       ▄▄
     ▄███▀▀██▄████████▄ ▄▀▀▀▀▀▀█▌
   ██▀▄▄▄██▀▄███▀ ▀▀████      ▄██
▄▀▀▀▄██▄▀▀▌████▒▒▒▒▒▒███     ▌▄▄▀
▌    ▐▀████▐███▒▒▒▒▒▐██▌
▀▄▄▄▄▀   ▀▀████▒▒▒▒▄██▀
          ▀▀█████████▀
        ▄▄██▀██████▀█
      ▄██▀     ▀▀▀  █
     ▄█             ▐▌
 ▄▄▄▄█▌              ▀█▄▄▄▄▀▀▄
▌     ▐                ▀▀▄▄▄▀
 ▀▀▄▄▀

2017-07-12 06:08:17 - (sanic)[INFO]: Goin' Fast @ http://0.0.0.0:8080
2017-07-12 06:08:17,495 INFO sanic(701) | Goin' Fast @ http://0.0.0.0:8080
2017-07-12 06:08:17 - (sanic)[INFO]: Starting worker [1400]
2017-07-12 06:08:17,513 INFO sanic(449) | Starting worker [1400]
2017-07-12 06:08:17 - (sanic)[INFO]: Starting worker [1401]
2017-07-12 06:08:17,528 INFO sanic(449) | Starting worker [1401]
2017-07-12 06:08:17 - (sanic)[INFO]: Starting worker [1402]
2017-07-12 06:08:17,553 INFO sanic(449) | Starting worker [1402]
2017-07-12 06:08:17 - (sanic)[INFO]: Starting worker [1403]
2017-07-12 06:08:17,557 INFO sanic(449) | Starting worker [1403]

I suspect the issue is due to this line:
https://github.com/argaen/aiocache/blob/master/aiocache/log.py#L3

Is there any easy way to fix this behaviour?

@argaen
Copy link
Member

argaen commented Jul 13, 2017

Hi @keattang, yeah I can reproduce. I guess this happens because both sanic and aiocache use bad patterns for how to deal with logging.

See sanic-org/sanic#758

I'll do some changes in the module for aiocache and do a minor release to fix this

@keattang
Copy link
Author

Awesome appreciate it!

@argaen
Copy link
Member

argaen commented Jul 15, 2017

@keattang this should be fixed in master. Thanks for reporting :)

@keattang
Copy link
Author

Awesome thanks!

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