Update main and second table with a before update trigger for message logging
First of all, if you want to add a new entry log for each insert/update operation, you should change userMessageLog's primary key. Otherwise you'll receive an error message due to duplicity.
Then, you can deal with trigger recursion by using: pg_trigger_depth(). You can get some examples in this questions:

Prevent recursive trigger in PostgreSQL.
Or at this fiddle I've set up using your table definitions.

Having said that, you can find another questions with some discussions about the use of pg_trigger_depth(), with points for or against of using it. Have a look at the answers of Evan Carrol and Erwin Brandstetter in this question:

Is pg_trigger_depth() bad to use for preventing trigger cascading (recursion)?

Personally, I'll use a function instead of a trigger.