How can I track statistics on how often a hook/error message is triggered?
I don't think you'll get 'statistics' as such without some coding yourself, I've never seen a module that does that sort of thing (but hey it's Drupal so there probably is one somewhere).

Failing that I think your best bet would be to use the the watchdog() function, combined with enabling the dblog module on your site. You can use it like so:

if (empty($message-&gt;thread_id) &amp;&amp; strlen($message-&gt;body) &lt; 200 ) {
  form_set_error('[body][value]', t('My custom message.'));

  global $user;
  watchdog('mymodule', 'My custom message for user @username', array('@username' =&gt; $user-&gt;name));
}


Every time that if statement is entered you'll get a message on the 'Recent log messages' page, where you can even filter by entries for your own module, giving you a basic idea of what's happening, when, and for whom.