Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

To do & Feature ideas 💡 #340

Closed
metachris opened this issue Oct 16, 2020 · 3 comments · Fixed by #386
Closed

To do & Feature ideas 💡 #340

metachris opened this issue Oct 16, 2020 · 3 comments · Fixed by #386

Comments

@metachris
Copy link
Owner

metachris commented Oct 16, 2020

To do:

  • Documentation strategy - currently the detail docs are in RST format and hosted on readthedocs. The docs would need a refreshing, to make sure it's all up to date and everything is working as intended. Thought: maybe better as markdown docs on GitHub, so we can more easily copy code between the README and other places?

This is an incomplete (and growing) list of possible features to implement:


Please comment to add more, as well as to indicate interest.

@metachris metachris changed the title Feature Ideas Feature ideas 💡 Oct 17, 2020
@metachris metachris changed the title Feature ideas 💡 To do & Feature ideas 💡 Nov 1, 2020
@HappyEinara
Copy link

HappyEinara commented Mar 16, 2021

Hey Chris, logzero is a real pleasure to use, so thank you! My suggestion is to import and expose the loglevel constants like logging.DEBUG as logzero.DEBUG. For simple applications of the kind you document, it would limit the boilerplate of having to import both logging and logzero, and make the use of logzero easier to document and understand.

There may be reasons why this is a bad idea. And certainly the current design means replacing logzero in an application is trivial, should it ever be necessary. But I think giving us the option to risk a future find-and-replace job if we need to is no big deal. Logzero is already quite opinionated (in a good way).

Of course, the constants you expose should be exactly equivalent to logging.DEBUG and co., the implementation of which seems straightforward.

In almost every project I write, this would let me do:

import logzero

logger = logzero.logger
logger.loglevel(logzero.INFO)

Which I think is nicer than

from logzero import logger
import logging

logger.loglevel(logging.INFO)

and more approachable to beginners who might not care to learn enough python to understand the wonderful logging framework stlib provides. Only logger = logzero.logger is admittedly a bit counterintuitive.

In practice, I think a tiny logging module that wraps the logging implementation and provides a basic .logger(name) function and .DEBUG etc. constants to all other modules is a good pattern that provides pluggability for all non-trivial apps. Then I can use logzero or any other solution as backing in that module.

But that then means avoiding the unnecessary import of logging just to get some constants to set the loglevel in a trivial cli that just uses logzero is all the more compelling.

@metachris
Copy link
Owner Author

metachris commented Mar 16, 2021 via email

@metachris
Copy link
Owner Author

Thanks @HappyEinara. Implemented in v1.7.0

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

Successfully merging a pull request may close this issue.

2 participants