2017 © Pedro Peláez
 

library error-log-parser

PHP error_log parser library.

image

tm/error-log-parser

PHP error_log parser library.

  • Monday, October 30, 2017
  • by tommymuehle
  • Repository
  • 3 Watchers
  • 8 Stars
  • 1,048 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 6 Versions
  • 18 % Grown

The README.md

error-log-parser

Build Status Minimum PHP Version GitHub license GitHub issues, (*1)

Simple PHP library to parse Apache or Nginx error-log file entries for further usage., (*2)

Install

Using Composer, (*3)

$ composer require tm/error-log-parser

or manually add this to composer.json, (*4)

{
    "require": {
        "tm/error-log-parser": "~1.1"
    }
}

Usage

Instantiate the class:, (*5)

use TM\ErrorLogParser\Parser; 
$parser = new Parser(Parser::TYPE_APACHE) // or TYPE_NGINX;

And then parse the lines:, (*6)

function getLines($file)
 {
    $f = fopen($file, 'r');
    if (!$f) throw new Exception();
    while ($line = fgets($f)) {
        yield $line;
    }
    fclose($f);
}

foreach (getLines('/var/log/apache2/error.log') as $line) {
    $entry = $parser->parse($line);
}

Where $entry hold all parsed data. For Apache:, (*7)

stdClass Object (
    [date] => "Tue Dec 29 08:14:45 2015"
    [type] => "warn"
    [client] => "193.158.15.243"
    [message] => "mod_fcgid: stderr: PHP Warning:  Division by zero in /var/www/kd/app.de/src/Calc.php on line 346, referer: https://www.app.de"
)

And for Nginx:, (*8)

stdClass Object (
    [date] => "2011/06/10 13:30:10"
    [type] => "error"
    [message] => "*1 directory index of "/var/www/ssl/" is forbidden"
    [client] => "86.186.86.232"
    [server] => "hotelpublisher.com"
    [request] => "GET / HTTP/1.1"
    [host] => "hotelpublisher.com"
)

Otherwise you can use the FormlessParser for formless log files:, (*9)

stdClass Object (
    [type] => "info"
    [message] => "23263#0: *1 directory index of "/var/www/ssl/" is forbidden, client: 86.186.86.232, server: hotelpublisher.com, request: "GET / HTTP/1.1", host: "hotelpublisher.com""
)

Contributing

Please refer to CONTRIBUTING.md for information on how to contribute., (*10)

The Versions

30/10 2017

dev-master

9999999-dev https://github.com/tommy-muehle/error-log-parser

PHP error_log parser library.

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

log parser apache error nginx error_log

30/10 2017

1.2.1

1.2.1.0 https://github.com/tommy-muehle/error-log-parser

PHP error_log parser library.

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

log parser apache error nginx error_log

27/09 2016

1.2.0

1.2.0.0 https://github.com/tommy-muehle/error-log-parser

PHP error_log parser library.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

log parser apache error nginx error_log

24/06 2016

1.1.1

1.1.1.0 https://github.com/tommy-muehle/error-log-parser

PHP error_log parser library.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

log parser apache error nginx error_log

15/01 2016

1.1

1.1.0.0 https://github.com/tommy-muehle/error-log-parser

PHP error_log parser library.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

log parser apache error nginx error_log

02/01 2016

1.0

1.0.0.0 https://github.com/tommy-muehle/error-log-parser

PHP error_log parser library.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

log parser apache error nginx error_log