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

bitter-ability-32190

12/21/2021, 3:46 PM
Should
--stats-log
supersede
level
? I have
level
set to
warn
, and it took me a while to figure out why my stats weren't being logged 😬
h

hundreds-father-404

12/21/2021, 3:48 PM
Probably not supersede. Imo you often get spaghetti code when introducing coupling like that But perhaps a warning in this situation? Iirc the code is stats_aggregator.py. I think you can request the LogLevel type as a parameter to the @rule
🤔 1
b

bitter-ability-32190

12/21/2021, 3:50 PM
I guess a second way of slicing it. Why does it
log
the stats instead of printing them (other than the obvious "it's in the option name")
"I want to see only warnings AND I want to see the stats" is a totally reasonable thing to request 😉
h

hundreds-father-404

12/21/2021, 3:58 PM
Ohhh hm I was confusing this with something more subtle, but I think this isn't true. I was thinking that we don't capture the stats info for "workunits" that aren't WARN or ERROR, but I think that's not true So, for stats-log, we have to log. There's no way to print to the console because it's not a goal-rule and we can't get exclusive access to Console. The best we could do is log at a higher level like WARN But probably a better solution is to use --log-levels-by-target, which lets you override to use INFO for just one part and WARN everywhere else
So, the warning would suggest using --log-levels-by-target to fix this, rather than --level
b

bitter-ability-32190

12/21/2021, 4:03 PM
The technical limitation makes sense, but I'll maintain logging feels goofy here 😉
What's the right key to use for
log-levels-by-target
?
Hmmmmm:
Copy code
level = "warn"
log_levels_by_target = {"pants.goal.stats_aggregator" = "info"}
Doesn't seem to work, even though (on a different run):
Copy code
0:42:38.47 [INFO] (pants.goal.stats_aggregator) Counters:
  local_cache_read_errors: 0
  local_cache_requests: 23
  ...
.
Either I'm doing something wrong or
log_levels_by_target
is broken 😢
Yeah, I tried swapping the levels to see if
log_levels_by_target
only worked in making this more quiet, but that didn't work either:
Copy code
level = "debug"
log_levels_by_target = {'pants.goal.stats_aggregator' = "warn"}
Copy code
11:21:40.91 [INFO] (pants.goal.stats_aggregator)
I'm going to file an issue, I think I know why
🙌 1
🚀 1