Skip to content

Commit

Permalink
Logger
Browse files Browse the repository at this point in the history
  • Loading branch information
teodoroleckie committed Apr 20, 2021
0 parents commit f0cde66
Show file tree
Hide file tree
Showing 29 changed files with 6,086 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
### Logger initialization:

```php

require_once "vendor/autoload.php";

use Tleckie\Log\Handler\StreamHandler;
use Tleckie\Log\Handler\FileHandler;
use Tleckie\Log\Level;
use Tleckie\Log\Log;

$handlers = [
new StreamHandler(Level::DEBUG),
new FileHandler(Level::DEBUG, '/tmp/error.log')
];

$log = new Log($handlers);

class DummyToString {
public function __toString(): string
{
return 'My string';
}
}

class DummySerialize implements \JsonSerializable {
public function jsonSerialize()
{
return [
'value1',
'value2'
];
}
}

$log->alert(new Exception('Test alert message'),[1,2]);
$log->critical('Test critical message: {A} => {B}', ['A' => '(A value)', 'B' => '(B value)']);
$log->info('Test info message');
$log->error(new Exception('Test error message'));
$log->emergency('Test emergency message');
$log->emergency(['{A}' => 155555, '{B}' => 99999], ['A' => '(A value)', 'B' => '(B value)']);
$log->emergency(['A' => 155555, 'B' => 99999]);
$log->emergency(new class(){});
$log->emergency(new DummyToString());
$log->emergency(new DummySerialized());
```

Empty file added bin/.gitkeep
Empty file.
45 changes: 45 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "tleckie/log",
"license": "LGPL-3.0-only",
"description": "Simple PSR-3 log",
"type": "library",
"homepage": "https://github.com/teodoroleckie/log",
"authors": [
{
"name": "Teodoro Leckie Westberg",
"email": "teodoroleckie@gmail.com"
}
],
"autoload": {
"psr-4": {
"Tleckie\\Log\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tleckie\\Log\\Tests\\": "tests/"
}
},
"provide": {

},
"require": {
"php": "^8",
"psr/log": "^1.1"
},
"require-dev": {
"infection/infection": "^0.21.5",
"phpunit/phpunit": "^9.5",
"mikey179/vfsstream": "^1.6",
"friendsofphp/php-cs-fixer": "v3.0.0-beta.2"
},
"config": {
"sort-packages": true,
"optimize-autoloader": true,
"vendor-dir": "vendor",
"bin-dir": "bin"
},
"scripts": {
"php-cs-fixer": "php-cs-fixer --rules=@PSR1"
}
}
Loading

0 comments on commit f0cde66

Please # to comment.