subjective-php/psr-log-mongodb 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

subjective-php/psr-log-mongodb

最新稳定版本:v2.1.0

Composer 安装命令:

composer require subjective-php/psr-log-mongodb

包简介

A concrete implementation of the PSR LoggerInterface using mongo

README 文档

README

Code Quality

Latest Stable Version Latest Unstable Version License

Total Downloads Monthly Downloads Daily Downloads

This is an implementation of PSR-3 using MongoDB as backend storage.

Document Structure

Each mongo document constructed will have the following fields.

  • timestamp The current UTC date/time
  • level The RFC-5424 Log Level
  • message The log message
  • context Extraneous information that does not fit well in a string

Example Document

{ "_id" : ObjectId("57fc0050fc77ae5c017e52b1"), "timestamp" : ISODate("2016-10-08T02:02:12.944Z"), "level" : "info", "message" : "api access", "context" : { "method" : "GET", "resource" : "/widgets/123", "status" : 200 } }

The logger does not handle log retention. Expire Data from Collections by Setting TTL

Basic Usage

<?php use SubjectivePHP\Psr\Log\MongoLogger; use MongoDB\Client; $collection = (new Client())->selectDatabase('testing')->selectCollection('logs'); $logger = new MongoLogger($collection); $logger->debug('Some debug info');

Message/Context Interpolation

The message may contain placeholders which can be replaced with values from the context array. In the example below the final logged message will be User chadicus was created

<?php use SubjectivePHP\Psr\Log\MongoLogger; use MongoDB\Client; $collection = (new Client())->selectDatabase('testing')->selectCollection('logs'); $logger = new MongoLogger($collection); $logger->info('User {username} was created', ['username' => 'chadicus']);

Requirements

PSR Log MongoDB requires PHP 7.0 (or later).

Composer

To add the library as a local, per-project dependency use Composer! Simply add a dependency on subjective-php/psr-log-mongodb to your project's composer.json.

composer require subjective-php/psr-log-mongodb

Contact

Developers may be contacted at:

Run Build

With a checkout of the code get Composer in your PATH and run:

composer install ./vendor/bin/phpunit ./vendor/bin/phpcs

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固