3 ms·
I'm intrigued by the stream wrapper idea, but I don't think your "change the format" is general enough... sure, you can change the format, as long as you change
by randallsquared 15y ago
I'm intrigued by the stream wrapper idea, but I don't think your "change the format" is general enough... sure, you can change the format, as long as you change it to something that uses the other arguments sprintf is being passed, but that's a pretty strong restriction. Maybe it would be workable if you had log() take optional argument(s) that represent the args to sprintf, too, but I'm not sure that it's worth it.
- lux 15y agoTrue, and using %1$s style references in the format in order to change their ordering is a lot uglier than overriding a method. In my last example, I did provide a formatMessage() which was the equivalent of the createLogMessage() for purposes of overriding. Best of both worlds :)