2017 © Pedro Peláez
 

library psr-log-mongodb

A concrete implementation of the PSR LoggerInterface using mongo

image

chadicus/psr-log-mongodb

A concrete implementation of the PSR LoggerInterface using mongo

  • Saturday, April 22, 2017
  • by chadicus
  • Repository
  • 0 Watchers
  • 1 Stars
  • 545 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 8 Versions
  • 37 % Grown

The README.md

PSR Log MongoDB

Code Quality, (*1)

Latest Stable Version Latest Unstable Version License, (*2)

Total Downloads Monthly Downloads Daily Downloads, (*3)

This is an implementation of PSR-3 using MongoDB as backend storage., (*4)

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, (*5)

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, (*6)

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, (*7)

<?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)., (*8)

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., (*9)

composer require subjective-php/psr-log-mongodb

Contact

Developers may be contacted at:, (*10)

Run Build

With a checkout of the code get Composer in your PATH and run:, (*11)

```sh composer install ./vendor/bin/phpunit ./vendor/bin/phpcs, (*12)

The Versions

22/04 2017

dev-master

9999999-dev

A concrete implementation of the PSR LoggerInterface using mongo

  Sources   Download

MIT

The Requires

 

The Development Requires

psr log mongo

22/04 2017

dev-develop

dev-develop

A concrete implementation of the PSR LoggerInterface using mongo

  Sources   Download

MIT

The Requires

 

The Development Requires

psr log mongo

22/04 2017

v1.1.3

1.1.3.0

A concrete implementation of the PSR LoggerInterface using mongo

  Sources   Download

MIT

The Requires

 

The Development Requires

psr log mongo

22/04 2017

v1.1.2

1.1.2.0

A concrete implementation of the PSR LoggerInterface using mongo

  Sources   Download

MIT

The Requires

 

The Development Requires

psr log mongo

08/03 2017

v1.1.1

1.1.1.0

A concrete implementation of the PSR LoggerInterface using mongo

  Sources   Download

MIT

The Requires

 

The Development Requires

psr log mongo

08/03 2017

dev-fea/better-exception-context

dev-fea/better-exception-context

A concrete implementation of the PSR LoggerInterface using mongo

  Sources   Download

MIT

The Requires

 

The Development Requires

psr log mongo

07/02 2017

v1.1.0

1.1.0.0

A concrete implementation of the PSR LoggerInterface using mongo

  Sources   Download

MIT

The Requires

 

The Development Requires

psr log mongo

11/10 2016

v1.0.0

1.0.0.0

A concrete implementation of the PSR LoggerInterface using mongo

  Sources   Download

MIT

The Requires

 

The Development Requires

psr log mongo