如何在drupal中记录错误消息 [英] How to log error message in drupal

查看:127
本文介绍了如何在drupal中记录错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将自己的错误消息(例如:由于无效的用户日期条目导致的错误)记录在 php 程序中生成 drupal错误日志

How to log our own error messages(for ex: error due to invalid user date entry) which is generated in php program to drupal error log.

推荐答案

您可以使用 看门狗功能

You can use the watchdog function :

watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL)

引用手册,参数如下:


  • $ type 此消息所属的类别。

  • $ message 要存储在日志中的消息。 >
  • $ variables 显示消息中要替换的变量数组,如果消息已被翻译或无法翻译,则为NULL。

  • $ severity 根据RFC 3164

  • $的消息的严重性链接链接关联消息。

  • $type The category to which this message belongs.
  • $message The message to store in the log.
  • $variables Array of variables to replace in the message on display or NULL if message is already translated or not possible to translate.
  • $severity The severity of the message, as per RFC 3164
  • $link A link to associate with the message.

错误级别可以在 watchdog_severity_levels 。对于一个错误,您最有可能使用 WATCHDOG_ERROR ,或者甚至可能更多的是关键,具体取决于错误的类型。

And the error levels can be found on the page of watchdog_severity_levels. For an error, you'll most probably use WATCHDOG_ERROR, or maybe even something more "critical", depending on the kind of error.

这篇关于如何在drupal中记录错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆