aio-libs / aiohttp-devtools

dev tools for aiohttp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Logging option

kination opened this issue · comments

  • aiohttp-devtools version:
    Newest
  • aiohttp version:
    3.3.2
  • python version:
    3.6
  • Platform:
    MacOS

Issue Summary

Question about logging, not issue.

Detail

First, thanks for good tool. It has been a help.

This is not in document, but found while looking on cli.py.
In runserver method, -v seems setting up the log, by true/false.

@click.option('-v', '--verbose', is_flag=True, help=verbose_help)

But in log.py method, there are level for this.

LOG_FORMATS = {
    logging.DEBUG: {'fg': 'white', 'dim': True},
    logging.INFO: {'fg': 'green'},
    logging.WARN: {'fg': 'yellow'},
}

How about making log option as level name, instead of true/false?
If I'm thinking wrong, or if you have other plan, please let me know.

Thanks.

It appears to default to INFO, then -v changes it to DEBUG: https://github.com/aio-libs/aiohttp-devtools/blob/master/aiohttp_devtools/logs.py#L112

This seems like a very reasonable approach for a local dev tool. I'm not sure there's really any need for anything more complex than that, and it should be possible to override this within your application code.

If we were to consider changing something, I'd probably do something -v decreases the logging level by 10, while -q increases it by 10, allowing you to do it multiple times. e.g. -qq would change the level to ERROR. But, I'm not convinced this is worth implementing in a local dev tool, so I won't be spending any time to write this.