0

I have sensitive data that is sent to a Drupal instance and I don't want it to be logged. I can filter out sensitive values with simple string replacements for my own calls to watchdog(), but for PHP errors and other modules making watchdog() calls, the data may be logged and this needs to be filtered too.

| improve this question | | | | |
2

Assuming you're dealing with the dblog module, this is a workable solution:

  1. Disable the dblog module
  2. Copy dblog_watchdog into your own module's hook_watchdog implementation
  3. Wrap each of the appropriate database field entries with your function to sanitise the string, e.g.

    Database::getConnection('default', 'default')->insert('watchdog')
      ->fields(array(
        'uid' => $log_entry['uid'],
        'type' => mymodule_sanitise(drupal_substr($log_entry['type'], 0, 64)),
    ...
    

If you have other watchdog modules in use, you'll need a copy/edited hook_watchdog version for each of them too.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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