Function: erc-save-buffer-in-logs

Append BUFFER contents to the log file, if logging is enabled.
If BUFFER is not provided, current buffer is used.
Logging is enabled if `erc-logging-enabled' returns non-nil.

This is normally done on exit, to save the unsaved portion of the
buffer, since only the text that runs off the buffer limit is logged

You can save every individual message by putting this function on
`erc-insert-post-hook'. (fn &optional BUFFER)