log: make the logging functions handle > 1024 bytes correctly