I have a similar function called DebugPrintf, which prints to both serial and a log file.
One warning: beware for buffer-overflows. In an earlier version my buffer was too small for the text printed. The result was a nice red blinking SOS for hard fault, caused by overwriting the heap. Reset would give the same SOS, so all I could do to unbrick my Spark Core was the factory reset. Luckily that worked!
Also note that using these functions will increase your code size, perhaps more than you would expect from a single function call…
This is a great initiaitve! You can generalize it to any Print instance, such as a TCPClient, UDP, or Serial. And for convenience, also provide a default buffer size, but allow overrides, like this: