2017 © Pedro Peláez
 

library monolog-parser

A parser for monolog log entries

image

ddtraceweb/monolog-parser

A parser for monolog log entries

  • Thursday, June 25, 2015
  • by ddtraceweb
  • Repository
  • 2 Watchers
  • 19 Stars
  • 90,783 Installations
  • PHP
  • 7 Dependents
  • 0 Suggesters
  • 22 Forks
  • 1 Open issues
  • 15 Versions
  • 5 % Grown

The README.md

Monolog Parser Build Status

A simple library for parsing monolog logfiles., (*1)

Installation

You can install the library using composer by adding ddtraceweb/monolog-parser to your composer.json., (*2)

Usage

  • 1 days of logs
    require_once 'path/to/vendor/autoload.php';

    use Dubture\Monolog\Reader\LogReader;

    $logFile = '/path/to/some/monolog.log';
    $reader = new LogReader($logFile);

    foreach ($reader as $log) {
        echo sprintf("The log entry was written at %s. \n", $log['date']->format('Y-m-d h:i:s'));
    }

    $lastLine = $reader[count($reader)-1];
    echo sprintf("The last log entry was written at %s. \n", $lastLine['date']->format('Y-m-d h:i:s'));

  • options unlimited days logs
    require_once 'path/to/vendor/autoload.php';

    use Dubture\Monolog\Reader\LogReader;

    $logFile = '/path/to/some/monolog.log';
    $reader = new LogReader($logFile, 0);

    foreach ($reader as $log) {
        echo sprintf("The log entry was written at %s. \n", $log['date']->format('Y-m-d h:i:s'));
    }

    $lastLine = $reader[count($reader)-1];
    echo sprintf("The last log entry was written at %s. \n", $lastLine['date']->format('Y-m-d h:i:s'));

  • options 2 days logs
    require_once 'path/to/vendor/autoload.php';

    use Dubture\Monolog\Reader\LogReader;

    $logFile = '/path/to/some/monolog.log';
    $reader = new LogReader($logFile, 2);

    foreach ($reader as $log) {
        echo sprintf("The log entry was written at %s. \n", $log['date']->format('Y-m-d h:i:s'));
    }

    $lastLine = $reader[count($reader)-1];
    echo sprintf("The last log entry was written at %s. \n", $lastLine['date']->format('Y-m-d h:i:s'));

  • Add custom pattern

require_once 'path/to/vendor/autoload.php'; use Dubture\Monolog\Reader\LogReader; $logFile = '/path/to/some/monolog.log'; $reader = new LogReader($logFile); $pattern = '/\[(?P<date>.*)\] (?P<logger>[\w-\s]+).(?P<level>\w+): (?P<message>[^\[\{]+) (?P<context>[\[\{].*[\]\}]) (?P<extra>[\[\{].*[\]\}])/'; $reader->getParser()->registerPattern('newPatternName', $pattern); $reader->setPattern('newPatternName'); foreach ($reader as $log) { echo sprintf("The log entry was written at %s. \n", $log['date']->format('Y-m-d h:i:s')); } $lastLine = $reader[count($reader)-1]; echo sprintf("The last log entry was written at %s. \n", $lastLine['date']->format('Y-m-d h:i:s'));

Bitdeli Badge, (*3)

The Versions

25/06 2015

dev-master

9999999-dev

A parser for monolog log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

by Robert Gruendler

25/06 2015

1.2.1

1.2.1.0

A parser for monolog log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

by Robert Gruendler

22/11 2013

1.2

1.2.0.0

A parser for monolog log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

by Robert Gruendler

19/08 2013

0.1.1

0.1.1.0

A parser for monolog log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

by Robert Gruendler

19/08 2013

1.1

1.1.0.0

A parser for monolog log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

by Robert Gruendler

18/08 2013

0.1.0

0.1.0.0

A parser for monolog log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

by Robert Gruendler

18/08 2013

0.0.9

0.0.9.0

A parser for monolog log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

by Robert Gruendler

17/08 2013

0.0.8

0.0.8.0

A parser for monolog log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

by Robert Gruendler

17/08 2013

0.0.7

0.0.7.0

A parser for monolog log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

by Robert Gruendler

11/08 2013

0.0.6

0.0.6.0

A parser for monolog log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

by Robert Gruendler

11/08 2013

0.0.5

0.0.5.0

A parser for monolog log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

by Robert Gruendler

11/08 2013

0.0.4

0.0.4.0

A parser for monolog log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

by Robert Gruendler

11/08 2013

0.0.3

0.0.3.0

A parser for monolog log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

by Robert Gruendler

17/03 2013

0.0.2

0.0.2.0

A parser for monolog log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

by Robert Gruendler

16/03 2013

0.0.1

0.0.1.0

A parser for monolog log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

by Robert Gruendler