大网数据广告活动
PHP 语言与运行手册

The MongoDB\Driver\Monitoring\LogSubscriber interface

· 52CE 我爱测

Classes implementing this interface may be registered as a subscriber and receive log messages from the extension. This is similar to stream-based debug logging (i.e. mongodb.debug) except that trace-level log messages are not received.

The MongoDB\Driver\Monitoring\LogSubscriber interface

(mongodb >=1.17.0)

Introduction

Classes implementing this interface may be registered as a subscriber and receive log messages from the extension. This is similar to stream-based debug logging (i.e. mongodb.debug) except that trace-level log messages are not received.

As with stream-based logging, it is only possible to register a logger globally using MongoDB\Driver\Monitoring\addSubscriber(). The extension is not able to distinguish log messages for individual MongoDB\Driver\Manager objects.

Interface synopsis

class MongoDB\Driver\Monitoring\LogSubscriber implements MongoDB\Driver\Monitoring\Subscriber {
/* Constants */
const int LEVEL_ERROR = 0;
const int LEVEL_CRITICAL = 1;
const int LEVEL_WARNING = 2;
const int LEVEL_MESSAGE = 3;
const int LEVEL_INFO = 4;
const int LEVEL_DEBUG = 5;
/* Methods */
abstract public function log(int $level, string $domain, string $message): void
}

Predefined Constants

MongoDB\Driver\Monitoring\LogSubscriber::LEVEL_ERROR

Error log level. An error condition that the extension is unable to report through its API. This is the most severe log level in the extension.

MongoDB\Driver\Monitoring\LogSubscriber::LEVEL_CRITICAL

Critical log level. An error condition with slightly less severity. This constant exists for consistency with libmongoc; however, the extension is unlikely to use it in practice.

MongoDB\Driver\Monitoring\LogSubscriber::LEVEL_WARNING

Warning log level. Indicates a situation where undesirable application behavior may occur.

MongoDB\Driver\Monitoring\LogSubscriber::LEVEL_MESSAGE

Message or notice log level. Indicates an event that is unusual but not problematic.

MongoDB\Driver\Monitoring\LogSubscriber::LEVEL_INFO

Info log level. High-level information about normal driver behavior.

MongoDB\Driver\Monitoring\LogSubscriber::LEVEL_DEBUG

Debug log level. Detailed information that may be helpful when debugging an application.

Table of Contents

来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
PHP Documentation Group
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。