MONGOLOG.SETMODULE(3) 1 MONGOLOG.SETMODULE(3)MongoLog::setModule - Sets the module(s) to be logged
SYNOPSIS
publicstatic void MongoLog::setModule (int $module)
DESCRIPTION
This function can be used to set which driver modules should be logged. The MongoLog module constants may be used with bitwise operators
to specify multiple modules.
<?php
// first, specify a logging level
MongoLog::setLevel(MongoLog::ALL);
// log replica set activity
MongoLog::setModule(MongoLog::RS);
// log replica sets and connection activity
MongoLog::setModule(MongoLog::RS|MongoLog::CON);
// log everything except IO activity
MongoLog::setModule(MongoLog::ALL & (~MongoLog::IO));
?>
Note that you must also call MongoLog.setLevel(3) to enable logging.
PARAMETERS
o $module
- The module(s) you would like to log.
PHP Documentation Group MONGOLOG.SETMODULE(3)
Check Out this Related Man Page
MONGOLOG(3) 1 MONGOLOG(3)The MongoLog classINTRODUCTION
Logging can be used to get detailed information about what the driver is doing. Logging is disabled by default, but this class allows you
to activate specific levels of logging for various parts of the driver. Some examples:
<?php
// print every log message possible
MongoLog::setLevel(MongoLog::ALL); // all log levels
MongoLog::setModule(MongoLog::ALL); // all parts of the driver
// print significant events about replica set failover
MongoLog::setLevel(MongoLog::INFO);
MongoLog::setModule(MongoLog::RS);
// print info- and diagnostic-level events for replica sets and connections
MongoLog::setLevel(MongoLog::INFO|MongoLog::FINE);
MongoLog::setModule(MongoLog::RS|MongoLog::CON);
?>
Note
By default, MongoLog emits all log messages as PHP notices. Depending on the SAPI you use, messages may be sent to stderr (for CLI)
or the web server's error log. If, after configuring MongoLog, log messages are not appearing as expected, ensure that the E_NOTICE
bit is included in error_reporting and that display_errors is on.
CLASS SYNOPSIS
MongoLog
MongoLog
Constants
o const int$MongoLog::NONE0
o const int$MongoLog::ALL31
level constants
o const int$MongoLog::WARNING1
o const int$MongoLog::INFO2
o const int$MongoLog::FINE4
module constants
o const int$MongoLog::RS1
o const int$MongoLog::POOL1
o const int$MongoLog::CON2
o const int$MongoLog::IO4
o const int$MongoLog::SERVER8
o const int$MongoLog::PARSE16
Fields
o privatestatic int$callback
o privatestatic int$level
o privatestatic int$module
Methods
o publicstatic callable MongoLog::getCallback (void )
o publicstatic int MongoLog::getLevel (void )
o publicstatic int MongoLog::getModule (void )
o publicstatic void MongoLog::setCallback (callable $log_function)
o publicstatic void MongoLog::setLevel (int $level)
o publicstatic void MongoLog::setModule (int $module)
PREDEFINED CONSTANTS MONGOLOG CONSTANTS
These constants can be used by both MongoLog.setLevel(3) and MongoLog.setModule(3).
o MongoLog::NONE - Log nothing.
o MongoLog::ALL - Log everything.
MONGOLOG LEVEL CONSTANTS
These constants can be used by MongoLog.setLevel(3).
o MongoLog::WARNING - Log events that are somewhat exceptional, but not quite worthy of an actual exception (e.g. recoverable con-
nection errors).
o MongoLog::INFO - Log events that may be of interest to administrators, but are not particularly noteworthy (e.g. option parsing,
authentication steps).
o MongoLog::FINE - Log most events that the driver performs (e.g. server selection, socket communication). Depending on the module
being logged, this can be extremely noisy and is primarily useful for debugging.
MONGOLOG MODULE CONSTANTS
These constants can be used by MongoLog.setModule(3).
o MongoLog::CON - Log connection activity. Creating new connections, authentication, pinging, timeouts, etc.
o MongoLog::IO - Log traffic to/from the database. Unless your program is trivial, this will create an enormous number of log mes-
sages.
o MongoLog::PARSE - Log parsing of the connection string and options when constructing MongoClient.
o MongoLog::POOL - Previously used to log connection pool activity. This option is now a deprecated alias of MongoLog::RS.
o MongoLog::RS - Log replica set activity. Failovers, read preference selection, etc.
o MongoLog::SERVER - Previously used to log server status changes. This option is deprecated in favor of MongoLog::RS.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 1.3.0 | |
| | |
| | Added MongoLog::CON and deprecated Mon- |
| | goLog::POOL and MongoLog::SERVER. |
| | |
+--------+---------------------------------------------------+
PHP Documentation Group MONGOLOG(3)