Skip to content

Commit

Permalink
removed laminas-log dependency and kept stream functionality from it
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergiu committed Aug 26, 2024
1 parent 62dec30 commit bc991fc
Show file tree
Hide file tree
Showing 41 changed files with 2,231 additions and 130 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ return [
'writers' => [
'FileWriter' => [
'name' => 'FileWriter',
'priority' => \Laminas\Log\Logger::ALERT, // this is equal to 1
'priority' => \Dot\Log\Manager\Logger::ALERT, // this is equal to 1
'options' => [
'stream' => __DIR__ . '/../../log/dk.log',
],
Expand Down Expand Up @@ -113,15 +113,15 @@ return [
'writers' => [
'FileWriter' => [
'name' => 'FileWriter',
'priority' => \Laminas\Log\Logger::ALERT,
'priority' => \Dot\Log\Manager\Logger::ALERT,
'options' => [
'stream' => __DIR__ . '/../../log/dk.log',
'filters' => [
'allMessages' => [
'name' => 'priority',
'options' => [
'operator' => '>=',
'priority' => \Laminas\Log\Logger::EMERG,
'priority' => \Dot\Log\Manager\Logger::EMERG,
]
],
],
Expand All @@ -130,15 +130,15 @@ return [
// Only warnings
'OnlyWarningsWriter' => [
'name' => 'stream',
'priority' => \Laminas\Log\Logger::ALERT,
'priority' => \Dot\Log\Manager\Logger::ALERT,
'options' => [
'stream' => __DIR__ . '/../../log/warnings_only.log',
'filters' => [
'warningOnly' => [
'name' => 'priority',
'options' => [
'operator' => '==',
'priority' => \Laminas\Log\Logger::WARN,
'priority' => \Dot\Log\Manager\Logger::WARN,
],
],
],
Expand All @@ -147,7 +147,7 @@ return [
// Warnings and more important messages
'WarningOrHigherWriter' => [
'name' => 'stream',
'priority' => \Laminas\Log\Logger::ALERT,
'priority' => \Dot\Log\Manager\Logger::ALERT,
'options' => [
'stream' => __DIR__ . '/../../log/important_messages.log',
'filters' => [
Expand All @@ -157,7 +157,7 @@ return [
// note, the smaller the priority, the more important is the message
// 0 - emergency, 1 - alert, 2- error, 3 - warn. .etc
'operator' => '<=',
'priority' => \Laminas\Log\Logger::WARN,
'priority' => \Dot\Log\Manager\Logger::WARN,
],
],
],
Expand Down Expand Up @@ -197,7 +197,7 @@ The following formats the message as JSON data:

```php
'formatter' => [
'name' => \Laminas\Log\Formatter\Json::class,
'name' => \Dot\Log\Manager\Formatter\Json::class,
],
```

Expand All @@ -220,7 +220,7 @@ return [
'writers' => [
'FileWriter' => [
'name' => 'FileWriter',
'priority' => \Laminas\Log\Logger::ALERT,
'priority' => \Dot\Log\Manager\Logger::ALERT,
'options' => [
'stream' => __DIR__ . '/../../log/dk.log',
// explicitly log all messages
Expand All @@ -229,12 +229,12 @@ return [
'name' => 'priority',
'options' => [
'operator' => '>=',
'priority' => \Laminas\Log\Logger::EMERG,
'priority' => \Dot\Log\Manager\Logger::EMERG,
],
],
],
'formatter' => [
'name' => \Laminas\Log\Formatter\Json::class,
'name' => \Dot\Log\Manager\Formatter\Json::class,
],
],
],
Expand All @@ -252,7 +252,7 @@ Basic usage of the logger is illustrated below.
The messages are written to see which logs are written and which are not written.

```php
use Laminas\Log\Logger;
use Dot\Log\Manager\Logger;
```

...
Expand Down
4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
],
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"psr/http-message": "^1.0 || ^2.0",
"laminas/laminas-servicemanager": "^3.22",
"laminas/laminas-log": "^2.17",
"dotkernel/dot-mail": "^4.1"
"laminas/laminas-validator": "^2.64"
},
"require-dev": {
"phpunit/phpunit": "^10.2",
Expand Down
2 changes: 1 addition & 1 deletion docs/book/v3/configuring-writer.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ return [
'writers' => [
'FileWriter' => [
'name' => 'FileWriter',
'priority' => \Laminas\Log\Logger::ALERT, // this is equal to 1
'priority' => \Dot\Log\Manager\Logger::ALERT, // this is equal to 1
'options' => [
'stream' => __DIR__ . '/../../log/dk.log',
],
Expand Down
6 changes: 3 additions & 3 deletions docs/book/v3/example-with-formatter.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ return [
'writers' => [
'FileWriter' => [
'name' => 'FileWriter',
'priority' => \Laminas\Log\Logger::ALERT,
'priority' => \Dot\Log\Manager\Logger::ALERT,
'options' => [
'stream' => __DIR__ . '/../../log/dk.log',
// explicitly log all messages
Expand All @@ -24,12 +24,12 @@ return [
'name' => 'priority',
'options' => [
'operator' => '>=',
'priority' => \Laminas\Log\Logger::EMERG,
'priority' => \Dot\Log\Manager\Logger::EMERG,
],
],
],
'formatter' => [
'name' => \Laminas\Log\Formatter\Json::class,
'name' => \Dot\Log\Manager\Formatter\Json::class,
],
],
],
Expand Down
12 changes: 6 additions & 6 deletions docs/book/v3/filtering-log-messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ return [
'writers' => [
'FileWriter' => [
'name' => 'FileWriter',
'priority' => \Laminas\Log\Logger::ALERT,
'priority' => \Dot\Log\Manager\Logger::ALERT,
'options' => [
'stream' => __DIR__ . '/../../log/dk.log',
'filters' => [
'allMessages' => [
'name' => 'priority',
'options' => [
'operator' => '>=',
'priority' => \Laminas\Log\Logger::EMERG,
'priority' => \Dot\Log\Manager\Logger::EMERG,
]
],
],
Expand All @@ -48,15 +48,15 @@ return [
// Only warnings
'OnlyWarningsWriter' => [
'name' => 'stream',
'priority' => \Laminas\Log\Logger::ALERT,
'priority' => \Dot\Log\Manager\Logger::ALERT,
'options' => [
'stream' => __DIR__ . '/../../log/warnings_only.log',
'filters' => [
'warningOnly' => [
'name' => 'priority',
'options' => [
'operator' => '==',
'priority' => \Laminas\Log\Logger::WARN,
'priority' => \Dot\Log\Manager\Logger::WARN,
],
],
],
Expand All @@ -65,7 +65,7 @@ return [
// Warnings and more important messages
'WarningOrHigherWriter' => [
'name' => 'stream',
'priority' => \Laminas\Log\Logger::ALERT,
'priority' => \Dot\Log\Manager\Logger::ALERT,
'options' => [
'stream' => __DIR__ . '/../../log/important_messages.log',
'filters' => [
Expand All @@ -75,7 +75,7 @@ return [
// note, the smaller the priority, the more important is the message
// 0 - emergency, 1 - alert, 2- error, 3 - warn etc.
'operator' => '<=',
'priority' => \Laminas\Log\Logger::WARN,
'priority' => \Dot\Log\Manager\Logger::WARN,
],
],
],
Expand Down
2 changes: 1 addition & 1 deletion docs/book/v3/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Basic usage of the logger is illustrated below.
The messages are written to see which logs are written and which are not written.

```php
use Laminas\Log\Logger;
use Dot\Log\Manager\Logger;
```

...
Expand Down
60 changes: 0 additions & 60 deletions log.global.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

return [
'dot_log' => [

'loggers' => [
//define log services here

//example 1 - stream logger
'stream_logger' => [
'writers' => [
'name' => 'stream',
Expand All @@ -24,63 +21,6 @@ return [
],
],
],

//example 2 - db logger
'db_logger' => [
'writers' => [
'name' => 'db',
'priority' => \Laminas\Log\Logger::INFO,
'options' => [
//service name of the database adapter
'db' => 'database',
'table' => 'log_table',

//optional, column map
'column' => [
'timestamp' => 'date',
'priority' => 'type',
'message' => 'event',
],

//optional, separator
'separator' => '-',

'formatter' => [
'name' => 'MyFormatter',
],

'filters' => [
[
'name' => 'MyFilter',
]
]
],
],
],

//example 3 - mail logger using a mail service from dot-mail library
'mail_logger' => [
'writers' => [
'name' => 'mail',
'priority' => \Laminas\Log\Logger::ERR,
'options' => [
'mail_service' => 'dot-mail.mail-service.service_name',

'subject_prepend_text' => '',

'formatter' => [
'name' => 'MyFormatter',
],

'filters' => [
[
'name' => 'MyFilter'
],
],
]
],
],

],
],
];
10 changes: 4 additions & 6 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
use Dot\Log\Factory\LoggerAbstractServiceFactory;
use Dot\Log\Factory\ProcessorPluginManagerFactory;
use Dot\Log\Factory\WriterPluginManagerFactory;
use Laminas\Log\FilterPluginManager;
use Laminas\Log\FormatterPluginManager;
use Laminas\Log\Logger;
use Laminas\Log\LoggerServiceFactory;
use Laminas\Log\ProcessorPluginManager;
use Laminas\Log\WriterPluginManager;
use Dot\Log\Manager\FilterPluginManager;
use Dot\Log\Manager\FormatterPluginManager;
use Dot\Log\Manager\ProcessorPluginManager;
use Dot\Log\Manager\WriterPluginManager;

class ConfigProvider
{
Expand Down
9 changes: 9 additions & 0 deletions src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace Dot\Log\Exception;

class InvalidArgumentException extends \InvalidArgumentException
{
}
9 changes: 9 additions & 0 deletions src/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace Dot\Log\Exception;

class RuntimeException extends \RuntimeException
{
}
2 changes: 1 addition & 1 deletion src/Factory/FilterPluginManagerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Dot\Log\Factory;

use Exception;
use Laminas\Log\FilterPluginManager;
use Dot\Log\Manager\FilterPluginManager;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Factory/FormatterPluginManagerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Dot\Log\Factory;

use Exception;
use Laminas\Log\FormatterPluginManager;
use Dot\Log\Manager\FormatterPluginManager;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
Expand Down
Loading

0 comments on commit bc991fc

Please sign in to comment.