My solution expands on Stuart Hickinbottom 's and xinfa tang 's answers by NOT printing the timestamp of repeated messages:
(defvar my-package--last-message nil
"Last message with timestamp appended to it.")
(defun my-package-ad-timestamp-message (format-string &rest args)
"Prepend timestamp to each message in message buffer.
Regarding your changes:
(defun switch-to-most-recent-buffer-in-mode (major-mode)
The first problem is that you used the name of a standard variable for your argument, which means that the real major-mode is shadowed by whatever you pass to your function. You should rename that to something else (mode would be safe).
The second problem is ...