https://pantsbuild.org/ logo
#development
Title
# development
h

hundreds-breakfast-49010

09/04/2020, 8:30 PM
once https://github.com/pantsbuild/pants/pull/10729 is merged, we'll have the ability to filter logs by target
cf. https://github.com/pantsbuild/pants/pull/10734#issuecomment-687325966 , it seems like we'll want to be able to start setting individual log messages with custom targets
👍 1
in rust I think we could've been doing this all along with the existing log macros, we just weren't previously
and in python I think we'll need a one-liner change in
logger.py
h

hundreds-father-404

09/04/2020, 8:39 PM
I definitely agree that we want this functionality in Python
h

hundreds-breakfast-49010

09/04/2020, 9:32 PM
actually I was mistake - we can already do this in python too
h

hundreds-father-404

09/04/2020, 9:32 PM
how so?
h

hundreds-breakfast-49010

09/04/2020, 9:33 PM
if we want a custom target, we can invoke
logger = logging.getLogger("some_name")
💯 1
and python logs logged with that logger with use that name as the target
logger = logging.getLogger(__name__)
is just a convention we use
👍 1
h

hundreds-father-404

09/04/2020, 9:35 PM
So you could have this in the same file:
Copy code
module_logger = logging.getLogger(__name__)
custom_logger = logging.getLogger("custom")
👍 1