Skip to content

Commit a72e675

Browse files
authored
Merge pull request #12 from OnrampLab/11-feat-override-log-singleton
Finish: override log singleton Close #11
2 parents 1310451 + a50620b commit a72e675

File tree

8 files changed

+17
-63
lines changed

8 files changed

+17
-63
lines changed

.circleci/config.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ commands:
77
- checkout
88
- restore_cache:
99
key: dependency-cache-composer-{{ checksum "composer.json" }}
10-
- run:
11-
name: Install php extensions
12-
command: |
13-
sudo docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd
14-
sudo docker-php-ext-install pcntl pdo_mysql
1510
- run:
1611
name: Install composer packages
1712
command: |
@@ -33,7 +28,7 @@ jobs:
3328
run_test:
3429
working_directory: ~/app
3530
docker:
36-
- image: circleci/php:7.4.3
31+
- image: cimg/php:7.4.26
3732
steps:
3833
- run_test
3934

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
A library with logging enhancement. Including:
88

9-
- `LoggerFacade` facade
9+
- Overriding `Log` facade
1010
- It extends default Laravel `Log` facade with logging adding class path and tracking id into context.
1111
- `LogglyHandler` class
1212
- It extends monolog's LogglyHandler with tags support
@@ -21,12 +21,6 @@ composer require onramplab/laravel-log-enhancement
2121

2222
### LoggerFacade
2323

24-
Replace the class of `Log` alias to `LoggerFacade` in `config/app.php` as aliases.
25-
26-
```php
27-
'Log' => Onramplab\LaravelLogEnhancement\Facades\LoggerFacade::class,
28-
```
29-
3024
The log json will look like this:
3125

3226
```json

composer.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
}
1212
],
1313
"minimum-stability": "dev",
14-
"prefer-stable":true,
14+
"prefer-stable": true,
1515
"require": {
1616
"monolog/monolog": "^1.12|^2.0",
1717
"ramsey/uuid": "^4.0.0"
@@ -22,9 +22,10 @@
2222
"illuminate/log": "^7.0",
2323
"illuminate/support": "^7.0",
2424
"mockery/mockery": "^1.3.2",
25+
"nunomaduro/larastan": "^1.0",
2526
"orchestra/database": "^5.0",
2627
"orchestra/testbench": "^5.0",
27-
"phpstan/phpstan": "^0.12.64",
28+
"phpstan/phpstan": "^1.7",
2829
"phpunit/phpunit": "^8.0",
2930
"sempro/phpunit-pretty-print": "1.2.2",
3031
"symfony/thanks": "^1.0"
@@ -36,12 +37,15 @@
3637
},
3738
"autoload-dev": {
3839
"psr-4": {
39-
"Onramplab\\LaravelLogEnhancement\\Tests\\":"tests/"
40+
"Onramplab\\LaravelLogEnhancement\\Tests\\": "tests/"
4041
}
4142
},
4243
"config": {
4344
"preferred-install": "dist",
44-
"sort-packages": true
45+
"sort-packages": true,
46+
"allow-plugins": {
47+
"symfony/thanks": true
48+
}
4549
},
4650
"scripts": {
4751
"test": "vendor/bin/phpunit",
@@ -51,10 +55,7 @@
5155
"laravel": {
5256
"providers": [
5357
"Onramplab\\LaravelLogEnhancement\\LaravelLogEnhancementServiceProvider"
54-
],
55-
"aliases": {
56-
"Onramplab": "Onramplab\\LaravelLogEnhancement\\LaravelLogEnhancementFacade"
57-
}
58+
]
5859
}
5960
}
6061
}

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '3.4'
22

33
services:
4-
php7:
5-
image: thecodingmachine/php:7.3-v3-slim-apache
4+
php:
5+
image: thecodingmachine/php:7.4-v4-slim-apache
66
volumes:
77
- ./:/var/www/html

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ parameters:
1212
# ignoreErrors:
1313
# - '#Unsafe usage of new static#'
1414

15-
excludes_analyse:
15+
excludePaths:
1616
- ./*/*/Tests/*.php
1717
- ./*/*/factories/*.php
1818
- ./*/*/Migrations/*.php

src/Facades/LoggerFacade.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/LaravelLogEnhancementFacade.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/LaravelLogEnhancementServiceProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,16 @@ private function routeConfiguration()
6060
*/
6161
public function register()
6262
{
63-
$this->app->singleton('laravel-log-enhancement-logger', function (Application $app) {
63+
$this->app->singleton('log', function (Application $app) {
6464
return new LogManager($app);
6565
});
6666
}
6767

6868
public function registerHooks()
6969
{
7070
Queue::before(function () {
71-
$this->app->forgetInstance('laravel-log-enhancement-logger');
72-
Facade::clearResolvedInstance('laravel-log-enhancement-logger');
71+
$this->app->forgetInstance('log');
72+
Facade::clearResolvedInstance('log');
7373
});
7474
}
7575

0 commit comments

Comments
 (0)