Skip to content

Maybe add some particularly useful examples to the docs? #2

@rpatterson

Description

@rpatterson

Awesome library! I wish I'd thought to google for this when writing dozens of DEBUG log messages with expensive string formatting, usually pprint. For example the following is incomplete, the expensive call to pprint.pformat may still happen for some logging configurations:

if logger.isEnabledFor(logging.DEBUG):
    logger.debug("Processing large data shape:\n%s", pprint.pformat(data_dict))

This might make a good example to include in the docs to help potential users imagine why they might use this. Untested, but in this case the expensive call should never happen unless this logging record is actually going to be emitted:

logger.debug(
    "Processing large data shape:\n%s",
    lazy_string.LazyString(functools.partial(pprint.pformat, data_dict)),
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions