2017 © Pedro Peláez
 

silverstripe-module silverstripe-loggerbridge

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

image

camspiers/silverstripe-loggerbridge

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  • Wednesday, April 25, 2018
  • by camspiers
  • Repository
  • 3 Watchers
  • 14 Stars
  • 28,928 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 8 Forks
  • 7 Open issues
  • 30 Versions
  • 4 % Grown

The README.md

SilverStripe Logger Bridge

Build Status Latest Stable Version Code Coverage, (*1)

Provides easy usage of PSR-3 loggers (like monolog) in SilverStripe 3.x. In SilverStripe 4.x and newer, PSR-3 support is built into the core system and this module is no longer required., (*2)

Installation (composer required)

$ composer require camspiers/silverstripe-loggerbridge:dev-master

Usage

  1. Create a config file in your mysite, e.g. "mysite/_config/logging.yml"
  2. Set up a PSR-3 logger service and add to the LoggerBridge constructor, (*3)

    Injector:
        Monolog:
            class: Monolog\Logger
            constructor:
                0: App
                1:
                    - '%$StreamHandler'
        StreamHandler:
            class: Monolog\Handler\StreamHandler
            constructor:
                0: '../../error.log'
        LoggerBridge:
            class: Camspiers\LoggerBridge\LoggerBridge
            constructor:
                0: '%$Monolog'

Changing the way errors display in development

By default Logger Bridge uses Whoops for the display of errors and exceptions. You can change to using SilverStripe error display by adding the following to your yml:, (*4)

Injector:
    LoggerBridge:
        properties:
            ErrorReporter: '%$LoggerBridgeDebugErrorReporter'

Advanced-style setup

This setup provides the following:, (*5)

  • Logging to a Sentry server, through a raven client (composer require raven/raven)
    • Uses one Sentry project for live and one Sentry project for test and dev
  • Logging to a file for error levels error and above
  • Logging to Chrome Logger when environment dev
    • Errors are displayed in the Chrome console instead of displaying in the webpage
  • Logging to FirePHP when environment dev
    • Errors are displayed in the Firebug console instead of displaying in the webpage
  • Logging of peak memory usage along with error
---
Except:
  environment: live
---
Injector:
  Raven:
    class: Raven_Client
    constructor:
      0: http://someraven.url/1

  Monolog:
    class: Monolog\Logger
    constructor:
      0: App
      1:
        - '%$RavenHandler'
        - '%$StreamHandler'
        - '%$ChromePHPHandler'
        - '%$FirePHPHandler'
      2:
        - '%$MemoryPeakUsageProcessor'

---
Only:
  environment: live
---
Injector:
  Raven:
    class: Raven_Client
    constructor:
      0: http://someraven.url/1
  Monolog:
    class: Monolog\Logger
    constructor:
      0: App
      1:
        - '%$RavenHandler'
        - '%$StreamHandler'
      2:
        - '%$MemoryPeakUsageProcessor'

---
Name: logging
---
Injector:
  LoggerBridge:
    class: Camspiers\LoggerBridge\LoggerBridge
    constructor:
      0: '%$Monolog'
      1: false
  RavenHandler:
    class: Monolog\Handler\RavenHandler
    constructor:
      0: '%$Raven'
  StreamHandler:
    class: Monolog\Handler\StreamHandler
    constructor:
      0: '../../error.log'
      1: 400
  ChromePHPHandler:
    class: Monolog\Handler\ChromePHPHandler
  FirePHPHandler:
    class: Monolog\Handler\FirePHPHandler
  MemoryPeakUsageProcessor:
    class: Monolog\Processor\MemoryPeakUsageProcessor

Attaching the logger as early as possible

SilverStripe currently doesn't provide any way to replace the default Debug error handlers prior to the database connection etc. But the following patch will use the Logger Bridge as early as possible., (*6)

To apply the patch, run the following from the framework directory of a 3.1.x-dev install., (*7)

patch -p1 < framework.patch

framework.patch, (*8)

diff --git a/core/Core.php b/core/Core.php
index bc3f583..4c9f59e 100644
--- a/core/Core.php
+++ b/core/Core.php
@@ -131,7 +131,7 @@ if(Director::isLive()) {
 /**
  * Load error handlers
  */
-Debug::loadErrorHandlers();
+Injector::inst()->get('LoggerBridge')->registerGlobalHandlers();


 ///////////////////////////////////////////////////////////////////////////////

Unit testing

Logger Bridge has good unit test converage. To run the unit tests:, (*9)

$ composer install --dev --prefer-dist
$ phpunit

License

SilverStripe Logger Bridge is released under the MIT license, (*10)

The Versions

25/04 2018

dev-master

9999999-dev

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

20/01 2016

1.0.0

1.0.0.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

30/04 2015

0.6.1

0.6.1.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

12/02 2015

0.6.0

0.6.0.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

12/02 2015

dev-psr3-exception-context

dev-psr3-exception-context

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

24/02 2014

0.5.2

0.5.2.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

02/02 2014

0.5.1

0.5.1.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

06/01 2014

0.5.0

0.5.0.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

22/11 2013

0.4.2

0.4.2.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

21/11 2013

0.4.1

0.4.1.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

21/11 2013

0.4.0

0.4.0.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

04/08 2013

0.3.4

0.3.4.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

31/07 2013

0.3.3

0.3.3.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

28/07 2013

0.3.2

0.3.2.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

27/07 2013

0.3.1

0.3.1.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

27/07 2013

0.3.0

0.3.0.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

24/07 2013

0.2.3

0.2.3.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

24/07 2013

0.2.2

0.2.2.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

24/07 2013

0.2.1

0.2.1.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

24/07 2013

0.2.0

0.2.0.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

24/07 2013

0.1.9

0.1.9.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

24/07 2013

0.1.8

0.1.8.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

23/07 2013

0.1.7

0.1.7.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

23/07 2013

0.1.6

0.1.6.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

23/07 2013

0.1.5

0.1.5.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

22/07 2013

0.1.4

0.1.4.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

22/07 2013

0.1.3

0.1.3.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

22/07 2013

0.1.2

0.1.2.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

22/07 2013

0.1.1

0.1.1.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires

22/07 2013

0.1.0

0.1.0.0

Provides a bridge between PSR-3 loggers (like monolog) and SilverStripe

  Sources   Download

MIT

The Requires

 

The Development Requires