Logs the output of a given target to file.
Makefile:
some-target :
@echo ✅ some-target is done!Shell:
$ make my-target!!bmakelib.logged
Logging target some-target to some-target-20230808-16221691536940-884103049.logged
exec 3>&1 4>&2 \
&& trap 'exec 2>&4 1>&3' 0 1 2 3 \
&& exec 1>/tmp/tmp.37mr7DpGnn/test_logged/some-target-20230808-16221691536940-884103049.logged 2>&1 \
&& make -f Makefile some-target
$ cat some-target-20230808-16221691536940-884103049.logged
✅ some-target is done!
Makefile:
some-target :
@echo 🤖 Done this and that.Shell:
$ make bmakelib.conf.logged.SILENT=yes \
bmakelib.conf.logged.ECHO_COMMAND=no \
some-target!!bmakelib.logged
$ cat some-target-20230808-16221691536940-834199518.logged
🤖 Done this and that.
- See
!!loggedbelow for a shorter name. - The name contains two consecutive exclamation marks (
!!). That is to denote that it runs a a new make process. - The log file name format is
TARGET_NAME-<time-format>.<microseconds>.logged. - See
bmakelib.conf.logged.output-dirto customise the output directory for logs. - See
bmakelib.conf.logged.time-formatto customise the timestamp format.
The directory where log files are written.
Precedence for resolving the output directory:
bmakelib.conf.logged.output-dir(Make variable)BMAKELIB_CONF_LOGGED_OUTPUT_DIR(environment variable)ROOT(legacy Make or environment variable)./(default)
Whether to define the convenience target %!!logged.
Set to 'no' before including bmakelib to disable.
Precedence:
bmakelib.conf.logged.convenience-target(Make variable)BMAKELIB_CONF_LOGGED_CONVENIENCE_TARGET(environment variable)yes(default)
Convenience target with a shorter and more intuitive name. It's a drop-in replacement for
!!bmakelib.logged.
Lets you write
some-target : other-target!!loggedor
$ make my-target!!logged
See also bmakelib.conf.logged.convenience-target.
If set to yes, causes !!bmakelib.logged to emit an info containing the log filename.
Precedence:
bmakelib.conf.logged.SILENT(Make variable)BMAKELIB_CONF_LOGGED_SILENT(environment variable)no(default)
If set to no, causes !!bmakelib.logged to not echo the actual command it runs.
Precedence:
bmakelib.conf.logged.ECHO_COMMAND(Make variable)BMAKELIB_CONF_LOGGED_ECHO_COMMAND(environment variable)yes(default)
The strftime-compatible format string used for the timestamp in log filenames.
Microseconds are always appended to avoid filename collisions.
Precedence:
bmakelib.conf.logged.time-format(Make variable)BMAKELIB_CONF_LOGGED_TIME_FORMAT(environment variable)%Y%m%d-%H%M%S(default)