This is drifting into a discussion better suited for Programmers Stack Exchange, but one option is to accept an enum instead of a String. However, the trade-off is that there is a finite # of log messages (or codes) that are known in advance. —
Michael Easter 56 secs ago