Even though a
@goal_rule is the only type of rule that can print to
stdout (via the special
Console type), any rule can log to stderr and change how the rule appears in the dynamic UI.
To add logging, use the
logging standard library module.
import logging logger = logging.getLogger(__name__) @rule def demo(...) -> Foo: logger.info("Inside the demo rule.") ...
You can use
logger.trace. You can then change your log level by setting the
--level option, e.g.
./pants -ldebug my-goal.
When you run
./pants lint, and
./pants test, you may notice that we "stream" the results. As soon as an individual process finishes, we print the result, rather than waiting for all the processes to finish and dumping at the end.
We also set the log level dynamically. If something succeeds, we log the result at
INFO, but if something fails, we use
Updated about 1 year ago