Hello I would like to know which of the following ways (or some other) of logging messages is better and why. I am writing lots of .install files since I create content types and fields programmatically and I often write statements as following:

$t = get_t();
watchdog('mymodule',$t('Field !field_name created.', array('!field_name' => $file_field_name)));


$t = get_t();
watchdog('mymodule',$t('Field !field_name created.'), array('!field_name' => $file_field_name));

Note: in the first example I am doing string replacement in the $t function in the second in the watchdog() function.

1 Answer 1


Just use this:

watchdog('mymodule', 'Field !field_name created.', array('!field_name' => $file_field_name));

watchdog() function will translate the string you pass as the second parameter. You shouldn't translate the message before passing it to the watchdog().

Check out this answer for more information and references.

Or consult the following document from Drupal's documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.