Skip to content

Use named loggers instead of the root logger #1604

Description

@sondrfos

datacontract-cli currently uses root logging functions such as:

logging.info(message)
logging.warning(message)
logging.error(message)

This makes it difficult for applications embedding datacontract-cli to configure its logs independently from application logs.

Would you consider using module-level named loggers throughout the package?

logger = logging.getLogger(__name__)

For example:

logger.info(message)
logger.warning(message)
logger.error(message)

This would create loggers under the shared datacontract namespace, such as datacontract.model.run, allowing consumers to configure the whole library:

logging.getLogger("datacontract").setLevel(logging.CRITICAL)

or configure individual modules separately.

Keeping the default propagate=True should preserve the current behavior for users relying on root handlers while providing applications with finer logging control.

I’d be happy to submit a pull request replacing the root logging calls with module-level named loggers if this approach is acceptable

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions