定制 district5/mondoc-log-handler 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

district5/mondoc-log-handler

最新稳定版本:1.0.1

Composer 安装命令:

composer require district5/mondoc-log-handler

包简介

A Monolog compatible log handler for the Mondoc library.

README 文档

README

CI

This library is a Monolog handler that logs to a MongoDB collection using the Mondoc library. It complements the Monolog library by providing a handler that logs to a MongoDB collection using Mondoc.

Installation...

composer require district5/mondoc-log-handler

Usage...

<?php
use District5\MondocLogHandler\Handler\MondocLogHandler;
use District5\MondocLogHandler\MondocLogConfig;
use Monolog\Level;
use Monolog\Logger;

// Set up MondocConfig
$client = new \MongoDB\Client('mongodb://localhost:27017');
\District5\Mondoc\MondocConfig::getInstance()->addDatabase(
    $client->selectDatabase('my_database'),
    'default' // This is the default connection id
)

// Set up MondocLogConfig
$config = MondocLogConfig::getInstance()->setConnectionId(
    'default' // This is the default connection id
)->setCollectionName(
    'mondoc_log' // This is the default collection name
);

// Set up the logger
$logger = new Logger('my_app');

$handler = new MondocLogHandler(
    $level = Level::Debug,
    $bubble = true
);
$handler->setFormatter(
    new LineFormatter('%message%') // This is the default formatter and format
);
$logger->pushHandler($handler);
$logger->info('A test log from MondocLogHandler');
$lastLogModel = $handler->getLastLog();

echo $lastLogModel->getMessage(); // 'A test log from MondocLogHandler'

Testing...

composer install
./vendor/bin/phpunit

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: mit
  • 更新时间: 2024-07-25