From d8baef6648da6c7ac4004dc0185ec41c01dcc63b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Helfensd=C3=B6rfer?= Date: Thu, 15 Feb 2018 10:22:48 +0100 Subject: [PATCH] Compatible to laravel 5.6 --- .gitignore | 1 + README.md | 40 +--- composer.json | 12 +- composer.lock | 465 ++++++++++++++++++++++++++++++++++++++++ src/DatabaseHandler.php | 1 - src/DatabaseLogger.php | 21 ++ 6 files changed, 504 insertions(+), 36 deletions(-) create mode 100644 .gitignore create mode 100644 composer.lock create mode 100644 src/DatabaseLogger.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..48b8bf9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +vendor/ diff --git a/README.md b/README.md index be850c4..b9a89c2 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,6 @@ # Laravel DatabaseLogger -[![Latest Version on Packagist][ico-version]][link-packagist] -[![Software License][ico-license]](LICENSE.md) - -Laravel package to log messages into the database instead of, or in addition to, a file. +Laravel package to log messages into a database. ## Install @@ -15,37 +12,22 @@ $ composer require visualappeal/databaselogger ## Usage -Add the following lines just before the `return $app` statement in `bootstrap/app.php`: +Add the following lines in your `config/logging.php`: ``` -$app->configureMonologUsing(function ($monolog) { - $monolog->pushHandler(new VisualAppeal\DatabaseLogger\DatabaseHandler); - - // If you want to log to files too, e.g. the application has no database connections - // or the database is down. - $levels = [ - 'debug' => Monolog\Logger::DEBUG, - 'info' => Monolog\Logger::INFO, - 'notice' => Monolog\Logger::NOTICE, - 'warning' => Monolog\Logger::WARNING, - 'error' => Monolog\Logger::ERROR, - 'critical' => Monolog\Logger::CRITICAL, - 'alert' => Monolog\Logger::ALERT, - 'emergency' => Monolog\Logger::EMERGENCY, - ]; - - $monolog->pushHandler(new Monolog\Handler\RotatingFileHandler( - storage_path('/logs/laravel.log'), - 7, - $levels[env('APP_LOG_LEVEL')] - )); -}); - -return $app; +'db' => [ + 'driver' => 'custom', + 'via' => VisualAppeal\DatabaseLogger\DatabaseLogger::class, + 'level' => env('LOG_LEVEL', 'debug'), +], ``` ## Change log +### 1.2.0 + +* New logging class compatible to Laravel 5.6 + ### 1.0.0 * First release diff --git a/composer.json b/composer.json index aaf0470..bb65fa3 100644 --- a/composer.json +++ b/composer.json @@ -4,22 +4,22 @@ "description": "Laravel package to log messages into the database instead of a file.", "keywords": [ "VisualAppeal", - "DatabaseLogger", - "Laravel" + "database", + "logger", + "logging", + "laravel" ], "homepage": "https://github.com/VisualAppeal/DatabaseLogger", "license": "MIT", "authors": [ { "name": "VisualAppeal", - "email": "tim@visualappeal.de", - "homepage": "https://github.com/visualappeal", - "role": "Developer" + "email": "tim@visualappeal.de" } ], "require": { "php" : ">=5.6", - "illuminate/support": "5.*" + "illuminate/support": "5.6.*" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..35a0322 --- /dev/null +++ b/composer.lock @@ -0,0 +1,465 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "content-hash": "3cc4187b496216cc11c150f264170f42", + "packages": [ + { + "name": "doctrine/inflector", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/inflector.git", + "reference": "5527a48b7313d15261292c149e55e26eae771b0a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/5527a48b7313d15261292c149e55e26eae771b0a", + "reference": "5527a48b7313d15261292c149e55e26eae771b0a", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^6.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Common String Manipulations with regard to casing and singular/plural rules.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "inflection", + "pluralize", + "singularize", + "string" + ], + "time": "2018-01-09T20:05:19+00:00" + }, + { + "name": "illuminate/contracts", + "version": "v5.6.3", + "source": { + "type": "git", + "url": "https://github.com/illuminate/contracts.git", + "reference": "f5d3ca46ec931e78fe961e52940e56fb7a0e6707" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/contracts/zipball/f5d3ca46ec931e78fe961e52940e56fb7a0e6707", + "reference": "f5d3ca46ec931e78fe961e52940e56fb7a0e6707", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "psr/container": "~1.0", + "psr/simple-cache": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.6-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Contracts\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Contracts package.", + "homepage": "https://laravel.com", + "time": "2018-01-30T14:30:39+00:00" + }, + { + "name": "illuminate/support", + "version": "v5.6.3", + "source": { + "type": "git", + "url": "https://github.com/illuminate/support.git", + "reference": "08f8b351a77efebfe3650e069ffa3f21a9a308d7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/support/zipball/08f8b351a77efebfe3650e069ffa3f21a9a308d7", + "reference": "08f8b351a77efebfe3650e069ffa3f21a9a308d7", + "shasum": "" + }, + "require": { + "doctrine/inflector": "~1.1", + "ext-mbstring": "*", + "illuminate/contracts": "5.6.*", + "nesbot/carbon": "^1.20", + "php": "^7.1.3" + }, + "replace": { + "tightenco/collect": "self.version" + }, + "suggest": { + "illuminate/filesystem": "Required to use the composer class (5.2.*).", + "symfony/process": "Required to use the composer class (~4.0).", + "symfony/var-dumper": "Required to use the dd function (~4.0)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.6-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Support\\": "" + }, + "files": [ + "helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Support package.", + "homepage": "https://laravel.com", + "time": "2018-02-04T20:30:42+00:00" + }, + { + "name": "nesbot/carbon", + "version": "1.22.1", + "source": { + "type": "git", + "url": "https://github.com/briannesbitt/Carbon.git", + "reference": "7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc", + "reference": "7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "symfony/translation": "~2.6 || ~3.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2", + "phpunit/phpunit": "~4.0 || ~5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.23-dev" + } + }, + "autoload": { + "psr-4": { + "Carbon\\": "src/Carbon/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Brian Nesbitt", + "email": "brian@nesbot.com", + "homepage": "http://nesbot.com" + } + ], + "description": "A simple API extension for DateTime.", + "homepage": "http://carbon.nesbot.com", + "keywords": [ + "date", + "datetime", + "time" + ], + "time": "2017-01-16T07:55:07+00:00" + }, + { + "name": "psr/container", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "time": "2017-02-14T16:28:37+00:00" + }, + { + "name": "psr/simple-cache", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "753fa598e8f3b9966c886fe13f370baa45ef0e24" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/753fa598e8f3b9966c886fe13f370baa45ef0e24", + "reference": "753fa598e8f3b9966c886fe13f370baa45ef0e24", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "time": "2017-01-02T13:31:39+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.7.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/78be803ce01e55d3491c1397cf1c64beb9c1b63b", + "reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2018-01-30T19:27:44+00:00" + }, + { + "name": "symfony/translation", + "version": "v3.4.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/translation.git", + "reference": "10b32cf0eae28b9b39fe26c456c42b19854c4b84" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/translation/zipball/10b32cf0eae28b9b39fe26c456c42b19854c4b84", + "reference": "10b32cf0eae28b9b39fe26c456c42b19854c4b84", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/config": "<2.8", + "symfony/dependency-injection": "<3.4", + "symfony/yaml": "<3.4" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.8|~3.0|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/finder": "~2.8|~3.0|~4.0", + "symfony/intl": "^2.8.18|^3.2.5|~4.0", + "symfony/yaml": "~3.4|~4.0" + }, + "suggest": { + "psr/log": "To use logging capability in translator", + "symfony/config": "", + "symfony/yaml": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Translation\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Translation Component", + "homepage": "https://symfony.com", + "time": "2018-01-18T22:16:57+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=5.6" + }, + "platform-dev": [] +} diff --git a/src/DatabaseHandler.php b/src/DatabaseHandler.php index ae97deb..b32a21a 100644 --- a/src/DatabaseHandler.php +++ b/src/DatabaseHandler.php @@ -3,7 +3,6 @@ namespace VisualAppeal\DatabaseLogger; use Illuminate\Support\Facades\DB; -use Illuminate\Support\Facades\Log; use Monolog\Handler\AbstractProcessingHandler; diff --git a/src/DatabaseLogger.php b/src/DatabaseLogger.php new file mode 100644 index 0000000..1ca1b5b --- /dev/null +++ b/src/DatabaseLogger.php @@ -0,0 +1,21 @@ +pushHandler(new DatabaseHandler($config['level'] ?? 'debug')); + return $logger; + } +}