This is the changes in MDL-13761 that were agreed with Eloy for probable inclusion in 1.9 branch:
a) Check length is under the limited for 'url' and 'info' parameters (only ones which are likely to potentially depend on user input) and trim to limited length, with '...', if needed.
b) If this trim happens, show debugging() info so that developers might notice they are logging something that can get too long.
c) In log view, if url field ends with ..., don't treat it as a link (as it won't work!).