我正在开发一个自定义模块，我想用自己的 类型 记录自己的日志条目，以便可以访问和过滤它们代码> admin/reports/dblog 。
I am developing a custom module, and I'd like to log my own log entries with their own type, so that they can be accessed and filtered at
But I can't find the appropiate function or script. Any suggestions?
watchdog() is what you are looking for. See the description of its parameters, in particular these:
$type: The category to which this message belongs. Can be any string, but the general practice is to use the name of the module calling
$typeparameter is limited to 16 characters; anything longer is truncated.
$severity: The severity of the message; one of the following values as defined in RFC 3164:
WATCHDOG_EMERGENCY: Emergency, system is unusable.
WATCHDOG_ALERT: Alert, action must be taken immediately.
WATCHDOG_CRITICAL: Critical conditions.
WATCHDOG_ERROR: Error conditions.
WATCHDOG_WARNING: Warning conditions.
WATCHDOG_NOTICE: (default) Normal but significant conditions.
WATCHDOG_INFO: Informational messages.
WATCHDOG_DEBUG: Debug-level messages.
$link: A link to associate with the message.
A possibly alternative for logging custom log entries, is to use the Rules module:
For D7, you can also use the Better Watchdog UI module, which comes with Rules Watchdog Integration. Some more details about this module (from its project page):
Upgrade watchdog entries to entities and replace default database log listing with a view, which grants advanced filtering options and filtered deletion as a bulk operation.
The module creates an entity wrapper around database log entries and enhances the watchdog listing by replacing it with a view. Beside type and severity, additional filter options were introduced such as date and author.
The possibility to change the number of listed entries per page has also been added.
Database clearing has also been customized, now admins can clear only the filtered entries, if needed.
The provided view is accessible to the admins and can be fully customized as any view, to fit one's needs.