otternq / dtail
Prints PHP Errors that have been logged to DynamoDB
Requires
- php: >=5.3.3
- aws/aws-sdk-php: 2.4.*@dev
- kevinlebrun/colors.php: 0.*
- monolog/monolog: 1.7.*
This package is not auto-updated.
Last update: 2024-11-05 03:07:32 UTC
README
Watch and search Logs entries stored in a DynamoDB table
Installing
DTail is available on Packagist.
To install with composer, add: "otternq/dtail": "dev-master"
to composer.json in the require section:
"require": { "php": ">=5.3.3", "otternq/dtail": "dev-master" }
then run php composer.phar update
(or php composer.phar install
depending on the situation) and let composer do the rest.
Usage
If you want to incoorperate this into another system, see Usage 1. If you just want to see the log entries, see Usage 2
###Usage 1
include "vendor/autoload.php"; use Colors\Color; use Aws\Common\Aws; use Aws\DynamoDb\DynamoDbClient; use DTail\DTail; $config = array( 'dyn-table' => 'PHPErrors', 'dyn-key' => YOUR_AWS_KEY, 'dyn-secret' => YOUR_AWS_SECRET, 'dyn-region' => 'us-east-1' ); $dynamodbClient = DynamoDbClient::factory(array( 'key' => $config['dyn-key'], 'secret' => $config['dyn-secret'], 'region' => $config['dyn-region'], ) ); $dtail = new DTail($dynamodbClient); $iterator = $dtail->get( $config['dyn-table'], 'PHPErrorReporter' ); foreach($iterator as $item) { var_dump($item); }
###Usage 2
If you just want to watch/search log files then use the bin/dtail
command:
bin/dtail -f /path/to/config/file.php
the config file will look like:
return array( 'dyn-table' => 'PHPErrors', 'dyn-key' => YOUR_AWS_KEY, 'dyn-secret' => YOUR_AWS_SECRET, 'dyn-region' => 'us-east-1' );
and the output will look like:
Channel Date Time Level Message Context
PHPErrorReporter 2013-11-14 WARNING Test []
PHPErrorReporter 2013-11-14 WARNING E_WARNING: Division by zero {"file":"/path/to/DTail/app.php","line":26}
PHPErrorReporter 2013-11-14 NOTICE E_NOTICE: Undefined variable: foo {"file":"/path/to/DTail/error.php","line":27}
PHPErrorReporter 2013-11-14 WARNING E_WARNING: Division by zero {"file":"/path/to/DTail/error.php","line":28}
PHPErrorReporter 2013-11-14 NOTICE E_NOTICE: Use of undefined constant T - assumed 'T' {"file":"/path/to/DTail/error.php","line":29}
PHPErrorReporter 2013-11-14 ERROR Uncaught exception {"exception":{"class":"Exception","message":"$arr has no element with index: dyn->key","file":"/path/to/DTail/Utils/Arr.php:26","trace":["/path/to/DTail/bin/app.php:36"]}}
DynamoDB
This tool was written to read log messages stored by monolog using the DynamoDB handler and the DynamoDB structure is displayed on Issue 259.