class MongoDbLog in MongoDB 8
Hierarchy
- class \Drupal\mongodb_dblog\MongoDbLog implements \Psr\Log\LoggerInterface uses RfcLoggerTrait
Expanded class hierarchy of MongoDbLog
1 string reference to 'MongoDbLog'
- mongodb_dblog.services.yml in mongodb_dblog/
mongodb_dblog.services.yml - mongodb_dblog/mongodb_dblog.services.yml
1 service uses MongoDbLog
File
- mongodb_dblog/
src/ MongoDbLog.php, line 15 - Contains \Drupal\mongodb\MongoDbLog.
Namespace
Drupal\mongodb_dblogView source
class MongoDbLog implements LoggerInterface {
use RfcLoggerTrait;
/**
* MongoDB collection factory.
*
* @var \Drupal\mongodb\MongoCollectionFactory
*/
protected $mongo;
/**
* The message's placeholders parser.
*
* @var \Drupal\Core\Logger\LogMessageParserInterface
*/
protected $parser;
/**
* Constructs a DbLog object.
*
* @param \Drupal\mongodb\MongoCollectionFactory $mongo
* The mongo collection factory.
* @param \Drupal\Core\Logger\LogMessageParserInterface $parser
* The parser to use when extracting message variables.
*/
public function __construct(MongoCollectionFactory $mongo, LogMessageParserInterface $parser) {
$this->mongo = $mongo;
$this->parser = $parser;
}
/**
* {@inheritdoc}
*/
public function log($level, $message, array $context = array()) {
// Remove any backtraces since they may contain an unserializable variable.
unset($context['backtrace']);
// Convert PSR3-style messages to String::format() style, so they can be
// translated too in runtime.
$message_placeholders = $this->parser
->parseMessagePlaceholders($message, $context);
$this->mongo
->get('watchdog')
->insert(array(
'uid' => $context['uid'],
'type' => substr($context['channel'], 0, 64),
'message' => $message,
'variables' => serialize($message_placeholders),
'severity' => $level,
'link' => substr($context['link'], 0, 255),
'location' => $context['request_uri'],
'referer' => $context['referer'],
'hostname' => substr($context['ip'], 0, 128),
'timestamp' => $context['timestamp'],
));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MongoDbLog:: |
protected | property | MongoDB collection factory. | |
MongoDbLog:: |
protected | property | The message's placeholders parser. | |
MongoDbLog:: |
public | function |
Overrides RfcLoggerTrait:: |
|
MongoDbLog:: |
public | function | Constructs a DbLog object. | |
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function |