GNOME Bugzilla – Bug 689664
format.printf(): New API
Last modified: 2015-10-28 00:41:59 UTC
While writing an app, I kept finding myself doing: print(format.vprintf("%s %s", [arg1, arg2])) So this lets me do just: format.printf("%s %s", arg1, arg2) which is obviously way better.
Created attachment 230706 [details] [review] format.printf(): New API
Review of attachment 230706 [details] [review]: ::: modules/format.js @@ +57,3 @@ + let args = Array.prototype.slice.call(arguments); + let fmt = args.shift(); + print(vprintf(fmt, args)); Do you need the Array conversion? And why vprintf() returns a string while printf() actually prints? And on a related note, do we want gjs applications to print anything without going through log()? Especially if at some point log() is hooked to g_log() and from that to the journal.
(In reply to comment #2) > Do you need the Array conversion? Yes, "arguments" is immutable. > And why vprintf() returns a string while printf() actually prints? Umm...yeah, that is confusing. But I can't change vprintf now... > And on a related note, do we want gjs applications to print anything without > going through log()? Especially if at some point log() is hooked to g_log() and > from that to the journal. So the larger question of how gjs does logging is definitely entagled with the question of how GLib does logging. I guess let's figure the second out first, and then we can just have gjs bound to it.
Looks good to me. Pushed to master now. Attachment 230706 [details] pushed as 2166fe9 - format.printf(): New API