Skip to content

Seldaek/monolol

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monolol

PSR-3 compliant lol-gger

QA

Build Status Scrutinizer Code Quality

INSTALLATION

Use composer :

{
    "require": {
	      "PHPointless/monolol" : "~1.0"
    }
}

HOW TO USE IT

Monolol provide new wrapper handler for Monolog : LolHandler. LolHandler will apply a Lolifier that will do some stuff on records handled by wrapped handler.

For example, we want to randomly shuffle log message words of all records that will be handled by a Monolog StreamHandler. Here is the code that will do the trick:

<?php

use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolol\Handlers\LolHandler;
use Monolol\Lolifiers;

$logger = new Logger('myLog');
$streamHandler = new StreamHandler(__DIR__ . 'monolol.log');

$lolHandler = new LolHandler($streamHandler, new Lolifiers\Shuffle());

$logger->pushHandler($lolHandler);

$logger->info('My littlest pony');
$logger->error('This burger has no cheese');

AVAILABLE LOLIFIERS

  • Shuffle: Words contained in record message will be randomly shuffled
  • Confuse: This lolifier will change randomly the log level of the record
  • GeekTime: Records will be handled only if it's 1:37pm (13:37)
  • Hangman: Wants to play hangman game while reading your logfiles ?
  • Hash: records message will be hashed with an algorithm randomly chosen
  • LaMerNoire: records message will be replaced by the following string : 'La mer Noire'
  • Mirror: records message content will be reversed (desrever eb lliw tnetnoc egassem sdrocer)
  • NotGiveAFuck: message of records having loglevel above INFO will be replaced by the following string : "It seems that your application has encountered an issue. But as we don't give a fuck, we will not tell you what is the problem. Have a good day"
  • Quote: records message will be replaced by a quote randomly chosen. Quote Lolifier needs a QuoteProvider. Here's an example of how to use it :
$quoteProvider = new Lolifiers\QuoteProviders\Kaamelot\Cadoc();
$lolHandler = new LolHandler($streamHandler, new Lolifiers\Quote($quoteProvider));

If you want quotes from more than one provider, you can use QuoteProviders\Collection

$quoteProvider = new Lolifiers\QuoteProviders\Collection();
$quoteProvider->add(new Lolifiers\QuoteProviders\Kaamelot\Cadoc())
              ->add(new Lolifiers\QuoteProviders\Kaamelot\Karadoc())
              ->add(new Lolifiers\QuoteProviders\Kaamelot\Perceval());
$lolHandler = new LolHandler($streamHandler, new Lolifiers\Quote($quoteProvider));
  • Warp: handle records will travel through the Warp
  • Yell: TO READ YOUR LOG FILES IN NOISY ENVIRONMENTS
  • Yolo: "An error? What are you talking about? There was no error!". All records having loglevel above INFO will not be handled
  • Tourette: Monolog is suffering a Tourette's syndrom. This lolifier needs a SwearWordsProvider. Here's an example of how to use it :
$swearWordsProvider = new Lolifiers\Lolifiers\SwearWordsProviders\DefaultProvider();
$lolHandler = new LolHandler($streamHandler, new Lolifiers\Tourette($swearWordsProvider));

About

PSR-3 Compliant lol-gger

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%