-
Notifications
You must be signed in to change notification settings - Fork 217
Allow pkg_install() to print destdir by default #889
Description
If destdir is a relative path, and/or if destdir is provided in the BUILD file, then sometimes the user does not know where the files are installed to. For a better UI, I would like to see this:
$ bazel run //package:my_install
Files are installed to /path/to/installed/dir!
There are a few difficulties / issues that has not been settled.
- The default log level is warning. However, the log
Files are installed to /path/to/installed/dir!appears to be best categorized as an INFO log. - If the user specified destdir in the command line, we might not want to print anything for brevity.
Hence, I propose the following changes:
-
The default log level for install.py.tpl should be INFO. All existing logs (CHDIR, CHOWN, etc.) are moved to
logging.debug()level. Then make the log level adjust with the following:if args.quiet: logging.getLogger().setLevel(logging.WARNING) elif loudness == 0: logging.getLogger().setLevel(logging.INFO) elif loudness == 1: logging.getLogger().setLevel(logging.DEBUG)That is:
- if -q only print warning/error (there are none of these logs now)
- by default print info
- if -v print debug level logs
With these two changes, the current command-line API is preserved (-v prints the logs)
-
If destdir is relative, OR if --destdir is not specified in the command line, then print
Files are installed to /path/to/installed/dir!at the INFO level. This covers the following cases:- If the user did not provide
--destdirin the command line, we fall back to the value in BUILD file, so we print the value to tell the user where the file goes. - If the user did provide a
--diestdirbut it is relative, we also print the value because the user might not know that it is below BUILD_WORKSPACE_DIRECTORY.
- If the user did not provide
Please let me know if these changes are acceptable. If so I'll make a pull request for this. Thanks!