On Wed, 2 Jul 2025 at 22:40, Bahman Movaqar <bah...@bahmanm.com> wrote:
> Somehow in the same vein is the work I did in bmakelib: > https://github.com/bahmanm/bmakelib/blob/main/doc/logged.md > That library is impressive. I wondered if GNU make could benefit from a function that fetches the current time - this might take away one reason to need to call out to perl. I selfishly used your idea to try implementing such a function in the extramake loadable module library for make: https://github.com/tnmurphy/extramake/commit/6faed2c6b7a335d1acec3fffd97cdaba8f4cb6ed The function works like this: $(time %Y-%m-%dT%H:%MZ) and $(time +) uses a default time format (can't use 0 params unfortunately for $(time) doesn't work) It's just a thin wrapper on the GNU libc clock_gettime() and strftime() functions. I don't know how easy it would be to implement this on non POSIX or non-recent systems which is a bit of a problem for putting it into mainline GNU Make. With $(time) you could implement logging with something like $(info $(time +) $(message)) at the top of the rule and if you wanted error levels you could have some sort of callable $(call log_warn, "message") which would then contain $(if $(LOG_WARN),$(info $(time+): $1)) so that setting LOG_WARN:=1 would enable warning level logs. Anyhow this is not a fully formed idea but I just felt that we lack a way to get the time/date and that might be useful for many things including logging. Cheers! :-) Tim