Message Module API
The Message module is a general logging utility tool which you can use to log any type of activity on a Drupal website. I’ve already written about how you can use Message module with Rules. If you’ve never used this module I would recommend that you read "Log Site Activity with Message and Rules" first, so you can get a good introduction on how to use Message module.
In this article we’ll look at creating messages programmatically via Entity’s entity_metadata_wrapper()
function. Finally we’ll look at how to load and display a message log. This is useful if you need to manually add a message to a template file.