Skip to content

Question about argschema logger #88

@njmei

Description

@njmei

I'm finding argschema super useful! But I've had one question/issue with regards to logging come up.

Because the argschema_parser is one of the first things called in most main scripts I was wondering if it was possible to prevent argschema from instantiating a logger? I couldn't find anything about it in the documentation pages.

The argschema logger caused another logger that I instantiated later in my main with basicConfig() to fail silently.
(see: https://docs.python.org/2/library/logging.html#logging.basicConfig)

I unfortunately, couldn't move my logger instantiation before invoking the argschema parser since the log filename and some other relevant variables needed to be obtained from argschema.

I was eventually able to find this workaround that worked:

# Remove root handler instantiated by argschema
for handler in logging.root.handlers[:]:
    logging.root.removeHandler(handler)

Do let me know if there's a better way for me to handle the issue. I'm very new to using both the logger and argschema...

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