bazel logging inside of a BUILD file

5.3k views Asked by At

Hi I want to see what is being passed to a rule that is defined in a rules.bzl file. So I would like to add just a logging statement inside of either the BUILD file or the rules.bzl file just to see what parameter was passed. I realize there is a whole --execution_log_binary_file and there is a good deal of stuff to read up on, but I am definitely looking to do something just once and quick and dirty. Do I import logging module? Is it something else? Thanks

2

There are 2 answers

4
Benjamin Peterson On BEST ANSWER

Use the builtin Starlark print() function in BUILD or .bzl files to dump values Bazel's console.

0
Brian Silverman On

bazel query --output=build //my/package:all will print out the definitions of all the targets created by macros called from my/package/BUILD by any .bzl file. This includes all the attributes passed to to various rules to create those targets.