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

witty-crayon-22786

02/04/2020, 6:58 PM
@bulky-television-48816: re: set/get logging destinations: cc @red-balloon-89377, @average-vr-56795
those methods are intended to propagate logging information between threads
so it's possible that https://github.com/pantsbuild/pants/issues/4999 is spawning the watcher thread before the parent's logging has been set up
i think that the python code will explicitly set the log destination for pantsd... but it's possible that that is too late for the scheduler construction
calls to
setup_pantsd_logger
, afaict
b

bulky-television-48816

02/04/2020, 7:01 PM
all traditional writes to stdout/stderr should end up in the log? Or do I need to log through the mechanism somehow?
w

witty-crayon-22786

02/04/2020, 7:02 PM
the logging mechanism is the right* way. it's just the destination that is not necessarily set correctly
in short: i suspect that https://github.com/pantsbuild/pants/blob/9ab9596c698d09e764165af177ed2ddcb1457b5d/src/python/pants/init/logging.py#L133-L151 might not be called in the correct place relative to creating the scheduler
we call it in a bunch of places
but in the pantsd case, we should ensure that it is called before we create the Scheduler... which is here, maybe? https://github.com/pantsbuild/pants/blob/9ab9596c698d09e764165af177ed2ddcb1457b5d/src/python/pants/pantsd/pants_daemon.py#L167-L169
r

red-balloon-89377

02/04/2020, 7:21 PM
I'm missing some context and I can't find it in the last couple of days of logs. Is there an issue or a pr I can read?
w

witty-crayon-22786

02/04/2020, 7:24 PM
@red-balloon-89377: see the branch in 4999: it uses the methods to
get/set
log destinations while spawning a thread
but i think it is doing so before logging has been directed to the appropriate places.
r

red-balloon-89377

02/04/2020, 7:27 PM
Thanks! I'll take a look tomorrow
(or follow along today, now with extra context :D)
w

witty-crayon-22786

02/04/2020, 7:42 PM
@bulky-television-48816: in the mean time, you might be able to change the
set_destination
call to an explicit call to
Destination::Pantsd
with a TODO
b

bulky-television-48816

02/04/2020, 10:54 PM
thanks, that did the trick
👍 1
w

witty-crayon-22786

02/05/2020, 1:57 AM
ok. so yea, i think that confirms the above. when that thread is being spawned, we haven't configured logging yet probably.
r

red-balloon-89377

02/05/2020, 2:16 PM
I’m still not sure of what problem @bulky-television-48816 is trying to solve, but in the branch logging is used the right way (read the destinations with
get
, set them with
set
, not manually setting them). My first gut reaction to trying to setup the logging to daemon is that it seems the wrong solution, the right solution being translating all the logging setup to happen before whatever the code that logs is.
Dang I’m really feeling the timezones on this one 🙂
w

witty-crayon-22786

02/05/2020, 3:07 PM
The issue is not when the logging happens: rather, when that thread is spawned.
But yes: need to move logging setup before the Scheduler is created