From 01518a93a9f15539b8e78202cd3bba1702d1dc17 Mon Sep 17 00:00:00 2001 From: bidi Date: Mon, 18 Mar 2024 12:00:54 +0200 Subject: [PATCH 01/13] added documentation --- docs/book/v3/README.md | 1 - docs/book/v3/SUMMARY.md | 3 - docs/book/v3/addingConfigProvider.md | 9 +++ docs/book/v3/configuringWriter.md | 43 ++++++++++++ docs/book/v3/exampleWithFormatter.md | 66 ++++++++++++++++++ docs/book/v3/filteringLogMessages.md | 92 ++++++++++++++++++++++++++ docs/book/v3/formattingMessages.md | 21 ++++++ docs/book/v3/groupingLogFilesByDate.md | 8 +++ 8 files changed, 239 insertions(+), 4 deletions(-) delete mode 100644 docs/book/v3/README.md delete mode 100644 docs/book/v3/SUMMARY.md create mode 100644 docs/book/v3/addingConfigProvider.md create mode 100644 docs/book/v3/configuringWriter.md create mode 100644 docs/book/v3/exampleWithFormatter.md create mode 100644 docs/book/v3/filteringLogMessages.md create mode 100644 docs/book/v3/formattingMessages.md create mode 100644 docs/book/v3/groupingLogFilesByDate.md diff --git a/docs/book/v3/README.md b/docs/book/v3/README.md deleted file mode 100644 index 349a768..0000000 --- a/docs/book/v3/README.md +++ /dev/null @@ -1 +0,0 @@ -## test book diff --git a/docs/book/v3/SUMMARY.md b/docs/book/v3/SUMMARY.md deleted file mode 100644 index 7ea8aec..0000000 --- a/docs/book/v3/SUMMARY.md +++ /dev/null @@ -1,3 +0,0 @@ -# Table of contents - -* [test book](README.md) diff --git a/docs/book/v3/addingConfigProvider.md b/docs/book/v3/addingConfigProvider.md new file mode 100644 index 0000000..8c73448 --- /dev/null +++ b/docs/book/v3/addingConfigProvider.md @@ -0,0 +1,9 @@ +## Adding The Config Provider +* Enter config/config.php +* If there is no entry for the config provider below, add it: + `\Dot\Log\ConfigProvider::class` +* Make sure it is added before with the Application-Specific components, eg.: \Frontend\App\ConfigProvider.php, `\Admin\App\ConfigProvider::class`, `MyProject\ConfigProvider::class` , etc. +* Open the `Dot\Log\ConfigProvider` +* In the dependencies section you will see an absctract factory (LoggerAbstractServiceFactory::class) +* This class responds to "selectors" instead of class names + - Instead of requesting the `Laminas\Log\Logger::class`from the container, dot-log.my_logger should be requested (or just `my_logger` if using laminas-log) \ No newline at end of file diff --git a/docs/book/v3/configuringWriter.md b/docs/book/v3/configuringWriter.md new file mode 100644 index 0000000..68f2bee --- /dev/null +++ b/docs/book/v3/configuringWriter.md @@ -0,0 +1,43 @@ +## Configuring the writer(s) +Loggers must have at least one writer. + +A writer is an object that inherits from `Laminas\Log\Writer\AbstractWriter`. A writer's responsibility is to record log data to a storage backend. (from laminas-log's writer documentation) + +### Writing to a file (stream) +It is possible separate logs into multiple files using writers and filters. +For example *warnings.log*, *errors.log*, *all_messages.log*. + +The following is the simplest example to write all log messages to `/log/dk.log` +```php +return [ + 'dot_log' => [ + 'loggers' => [ + 'my_logger' => [ + 'writers' => [ + 'FileWriter' => [ + 'name' => 'FileWriter', + 'priority' => \Laminas\Log\Logger::ALERT, // this is equal to 1 + 'options' => [ + 'stream' => __DIR__ . '/../../log/dk.log', + ], + ], + ], + ] + ], + ], +]; +``` +* The `FileWriter` key is optional, otherwise the writers array would be enumerative instead of associative. +* The writer name key is a developer-provided name for that writer, the writer name key is **mandatory**. + + +The writer priority key is not affecting the errors that are written, it is a way to organize writers, for example: + +1 - FILE +2 - SQL +3 - E-mail +It is the most important to write in the file, the sql or e-mail are more probably fail because the servers can be external and offline, the file is on the same server. + +The writer priority key is optional. + +To write into a file the key stream must be present in the writer options array. This is required only if writing into streams/files. \ No newline at end of file diff --git a/docs/book/v3/exampleWithFormatter.md b/docs/book/v3/exampleWithFormatter.md new file mode 100644 index 0000000..d301f84 --- /dev/null +++ b/docs/book/v3/exampleWithFormatter.md @@ -0,0 +1,66 @@ +### Example with formatter + +* The log is used through dot-log +* The logger name is my_logger +* Writes to file: log/dk.log +* Explicitly allows all the messages to be written +* Formats the messages as JSON + +```php + [ + 'loggers' => [ + 'my_logger' => [ + 'writers' => [ + 'FileWriter' => [ + 'name' => 'FileWriter', + 'priority' => \Laminas\Log\Logger::ALERT, + 'options' => [ + 'stream' => __DIR__ . '/../../log/dk.log', + // explicitly log all messages + 'filters' => [ + 'allMessages' => [ + 'name' => 'priority', + 'options' => [ + 'operator' => '>=', + 'priority' => \Laminas\Log\Logger::EMERG, + ], + ], + ], + 'formatter' => [ + 'name' => \Laminas\Log\Formatter\Json::class, + ], + ], + ], + ], + ], + ], + ], +]; +``` + +## Usage +Basic usage of the logger is illustraded below. + +The messages are written to see which logs are written and which are not written. +```php +use Laminas\Log\Logger; +``` +... +```php +$logger = $container->get('dot-log.my_logger'); + +/** @var Logger $logger */ +$logger->emerg('0 EMERG'); +$logger->alert('1 ALERT'); +$logger->crit('2 CRITICAL'); +$logger->err('3 ERR'); +$logger->warn('4 WARN'); +$logger->notice('5 NOTICE'); +$logger->info('6 INF'); +$logger->debug('7 debug'); +$logger->log(Logger::NOTICE, 'NOTICE from log()'); +``` \ No newline at end of file diff --git a/docs/book/v3/filteringLogMessages.md b/docs/book/v3/filteringLogMessages.md new file mode 100644 index 0000000..8913967 --- /dev/null +++ b/docs/book/v3/filteringLogMessages.md @@ -0,0 +1,92 @@ +## Filtering log messages + +As per PSR-3 document. + +The log levels are: emergency (0), alert (1), critical (2), error (3), warn (4), notice (5), info (6), debug (7) (in order of priority/importance) + +Although the plain Logger in Laminas Log is not fully compatible with PSR-3, it provides a way to log all of these message types. + + +The following example has three file writers using filters: +* First Example: `FileWriter` - All messages are logged in `/log/dk.log` +* Second Example: `OnlyWarningsWriter` - Only warnings are logged in `/log/warnings.log` +* Third Example: `WarningOrHigherWriter` - All important messages (`warnings` or more critical) are logged in `/log/important_messages.log` + +```php + [ + 'loggers' => [ + 'my_logger' => [ + 'writers' => [ + 'FileWriter' => [ + 'name' => 'FileWriter', + 'priority' => \Laminas\Log\Logger::ALERT, + 'options' => [ + 'stream' => __DIR__ . '/../../log/dk.log', + 'filters' => [ + 'allMessages' => [ + 'name' => 'priority', + 'options' => [ + 'operator' => '>=', + 'priority' => \Laminas\Log\Logger::EMERG, + ] + ], + ], + ], + ], + // Only warnings + 'OnlyWarningsWriter' => [ + 'name' => 'stream', + 'priority' => \Laminas\Log\Logger::ALERT, + 'options' => [ + 'stream' => __DIR__ . '/../../log/warnings_only.log', + 'filters' => [ + 'warningOnly' => [ + 'name' => 'priority', + 'options' => [ + 'operator' => '==', + 'priority' => \Laminas\Log\Logger::WARN, + ], + ], + ], + ], + ], + // Warnings and more important messages + 'WarningOrHigherWriter' => [ + 'name' => 'stream', + 'priority' => \Laminas\Log\Logger::ALERT, + 'options' => [ + 'stream' => __DIR__ . '/../../log/important_messages.log', + 'filters' => [ + 'importantMessages' => [ + 'name' => 'priority', + 'options' => [ + // 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, + ], + ], + ], + ], + ], + ], + ], + ], + ], +]; +``` + +As in the writer configuration, the developer can optionally use keys for associating the filters with a name. + +IMPORTANT NOTE: the operator for more important messages is <=, this is because the number representation is smaller for a more important message type. + +The filter added on the first writer is equal to not setting a filter, but it was been added to illustrate how to explicitly allow all messages. + +It was added opposite to the others just to demonstrate the other operator is also an option. + + + +More examples on filters: https://docs.laminas.dev/laminas-log/filters/ \ No newline at end of file diff --git a/docs/book/v3/formattingMessages.md b/docs/book/v3/formattingMessages.md new file mode 100644 index 0000000..c0e2c6c --- /dev/null +++ b/docs/book/v3/formattingMessages.md @@ -0,0 +1,21 @@ +## Formatting Messages + +When using `dot-log` or `laminas-log`, the logged value is not limited to a string. Arrays can be logged as well. + +For a better readability, these arrays can be serialized. + +Laminas Log provides String formatting, XML, JSON and FirePHP formatting. + + + +The formatter accepts following parameters: + +name - the formatter class (it must implement Laminas\Log\Formatter\FormatterInterface) +options - options to pass to the formatter constructor if required + + +The following formats the message as JSON data: + +'formatter' => [ +'name' => \Laminas\Log\Formatter\Json::class, +], \ No newline at end of file diff --git a/docs/book/v3/groupingLogFilesByDate.md b/docs/book/v3/groupingLogFilesByDate.md new file mode 100644 index 0000000..17480af --- /dev/null +++ b/docs/book/v3/groupingLogFilesByDate.md @@ -0,0 +1,8 @@ +## Grouping log files by date +By default, logs will be written to the same file: `log/dk.log`. +Optionally, you can use date format specifiers wrapped between curly braces in your FileWriter's `stream` option, automatically grouping your logs by day, week, month, year etc. +Examples: +* `log/dk-{Y}-{m}-{d}.log` will write every day to a different file (eg: log/dk-2021-01-01.log) +* `log/dk-{Y}-{W}.log` will write every week to a different file (eg: log/dk-2021-10.log) + +The full list of format specifiers is available [here](https://www.php.net/manual/en/datetime.format.php). \ No newline at end of file From 61115228fe85a6bd8c2390f10a143b62883620f3 Mon Sep 17 00:00:00 2001 From: bidi Date: Thu, 28 Mar 2024 16:22:39 +0200 Subject: [PATCH 02/13] updated documentation --- .github/workflows/docs-build.yml | 16 ++++++++ SECURITY.md | 40 +++++++++++++++++++ docs/book/{v3 => v4}/addingConfigProvider.md | 0 docs/book/{v3 => v4}/configuringWriter.md | 0 docs/book/{v3 => v4}/exampleWithFormatter.md | 0 docs/book/{v3 => v4}/filteringLogMessages.md | 0 docs/book/{v3 => v4}/formattingMessages.md | 0 .../book/{v3 => v4}/groupingLogFilesByDate.md | 0 docs/book/v4/usage.md | 22 ++++++++++ mkdocs.yml | 21 ++++++++++ 10 files changed, 99 insertions(+) create mode 100644 .github/workflows/docs-build.yml create mode 100644 SECURITY.md rename docs/book/{v3 => v4}/addingConfigProvider.md (100%) rename docs/book/{v3 => v4}/configuringWriter.md (100%) rename docs/book/{v3 => v4}/exampleWithFormatter.md (100%) rename docs/book/{v3 => v4}/filteringLogMessages.md (100%) rename docs/book/{v3 => v4}/formattingMessages.md (100%) rename docs/book/{v3 => v4}/groupingLogFilesByDate.md (100%) create mode 100644 docs/book/v4/usage.md create mode 100644 mkdocs.yml diff --git a/.github/workflows/docs-build.yml b/.github/workflows/docs-build.yml new file mode 100644 index 0000000..164e3d2 --- /dev/null +++ b/.github/workflows/docs-build.yml @@ -0,0 +1,16 @@ +name: docs-build + +on: + release: + types: [published] + workflow_dispatch: + +jobs: + build-deploy: + runs-on: ubuntu-latest + steps: + - name: Build Docs + uses: dotkernel/documentation-theme/github-actions/docs@main + env: + DEPLOY_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..391cd30 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,40 @@ +# Security Policy + +## Supported Versions + + +| Version | Supported | PHP Version | +|---------|--------------------|----------------------------------------------------------------------------------------------------| +| 4.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-log/3.4.7) | +| <= 3.x | :x: | | + + +## Reporting Potential Security Issues + +If you have encountered a potential security vulnerability in this project, +please report it to us at . We will work with you to +verify the vulnerability and patch it. + +When reporting issues, please provide the following information: + +- Component(s) affected +- A description indicating how to reproduce the issue +- A summary of the security vulnerability and impact + +We request that you contact us via the email address above and give the +project contributors a chance to resolve the vulnerability and issue a new +release prior to any public exposure; this helps protect the project's +users, and provides them with a chance to upgrade and/or update in order to +protect their applications. + + +## Policy + +If we verify a reported security vulnerability, our policy is: + +- We will patch the current release branch, as well as the immediate prior minor + release branch. + +- After patching the release branches, we will immediately issue new security + fix releases for each patched release branch. + diff --git a/docs/book/v3/addingConfigProvider.md b/docs/book/v4/addingConfigProvider.md similarity index 100% rename from docs/book/v3/addingConfigProvider.md rename to docs/book/v4/addingConfigProvider.md diff --git a/docs/book/v3/configuringWriter.md b/docs/book/v4/configuringWriter.md similarity index 100% rename from docs/book/v3/configuringWriter.md rename to docs/book/v4/configuringWriter.md diff --git a/docs/book/v3/exampleWithFormatter.md b/docs/book/v4/exampleWithFormatter.md similarity index 100% rename from docs/book/v3/exampleWithFormatter.md rename to docs/book/v4/exampleWithFormatter.md diff --git a/docs/book/v3/filteringLogMessages.md b/docs/book/v4/filteringLogMessages.md similarity index 100% rename from docs/book/v3/filteringLogMessages.md rename to docs/book/v4/filteringLogMessages.md diff --git a/docs/book/v3/formattingMessages.md b/docs/book/v4/formattingMessages.md similarity index 100% rename from docs/book/v3/formattingMessages.md rename to docs/book/v4/formattingMessages.md diff --git a/docs/book/v3/groupingLogFilesByDate.md b/docs/book/v4/groupingLogFilesByDate.md similarity index 100% rename from docs/book/v3/groupingLogFilesByDate.md rename to docs/book/v4/groupingLogFilesByDate.md diff --git a/docs/book/v4/usage.md b/docs/book/v4/usage.md new file mode 100644 index 0000000..f6c3a28 --- /dev/null +++ b/docs/book/v4/usage.md @@ -0,0 +1,22 @@ +## Usage +Basic usage of the logger is illustraded below. + +The messages are written to see which logs are written and which are not written. +```php +use Laminas\Log\Logger; +``` +... +```php +$logger = $container->get('dot-log.my_logger'); + +/** @var Logger $logger */ +$logger->emerg('0 EMERG'); +$logger->alert('1 ALERT'); +$logger->crit('2 CRITICAL'); +$logger->err('3 ERR'); +$logger->warn('4 WARN'); +$logger->notice('5 NOTICE'); +$logger->info('6 INF'); +$logger->debug('7 debug'); +$logger->log(Logger::NOTICE, 'NOTICE from log()'); +``` \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..c693567 --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,21 @@ +docs_dir: docs/book +site_dir: docs/html +extra: + project: Packages + current_version: v4 + versions: + - v4 +nav: + - Home: index.md + - v4: + - "Adding The Config Provider": v4/addingConfigProvider.md + - "Configuring the writer(s)": v4/configuringWriter.md + - "Grouping log files by date": v4/groupingLogFilesByDate.md + - "Filtering log messages": v4/filteringLogMessages.md + - "Formatting Messages": v4/formattingMessages.md + - "Usage": v4/usage.md +site_name: dot-log +site_description: "DotKernel log component extending and customizing" +repo_url: "https://github.com/dotkernel/dot-log" +plugins: + - search \ No newline at end of file From 3340c7fd701e59f8d7cc0eb4c6b1068ef84a5f49 Mon Sep 17 00:00:00 2001 From: bidi Date: Mon, 1 Apr 2024 12:03:04 +0300 Subject: [PATCH 03/13] updated documentation --- SECURITY.md | 4 ++-- mkdocs.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 391cd30..8446926 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -5,8 +5,8 @@ | Version | Supported | PHP Version | |---------|--------------------|----------------------------------------------------------------------------------------------------| -| 4.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-log/3.4.7) | -| <= 3.x | :x: | | +| 3.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-log/3.4.7) | +| <= 2.x | :x: | | ## Reporting Potential Security Issues diff --git a/mkdocs.yml b/mkdocs.yml index c693567..eecb239 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -18,4 +18,4 @@ site_name: dot-log site_description: "DotKernel log component extending and customizing" repo_url: "https://github.com/dotkernel/dot-log" plugins: - - search \ No newline at end of file + - search From 9d114f46b7ef12edde69aa792e3838a581e42778 Mon Sep 17 00:00:00 2001 From: bidi Date: Mon, 1 Apr 2024 12:06:23 +0300 Subject: [PATCH 04/13] updated documentation --- .github/workflows/docs-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs-build.yml b/.github/workflows/docs-build.yml index 164e3d2..1a7aa24 100644 --- a/.github/workflows/docs-build.yml +++ b/.github/workflows/docs-build.yml @@ -13,4 +13,4 @@ jobs: uses: dotkernel/documentation-theme/github-actions/docs@main env: DEPLOY_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From cbf09fe8b347fe091b4f1353bceacfe218917364 Mon Sep 17 00:00:00 2001 From: bidi Date: Mon, 1 Apr 2024 12:09:29 +0300 Subject: [PATCH 05/13] updated documentation --- docs/book/{v4 => v3}/addingConfigProvider.md | 0 docs/book/{v4 => v3}/configuringWriter.md | 0 docs/book/{v4 => v3}/exampleWithFormatter.md | 0 docs/book/{v4 => v3}/filteringLogMessages.md | 0 docs/book/{v4 => v3}/formattingMessages.md | 0 docs/book/{v4 => v3}/groupingLogFilesByDate.md | 0 docs/book/{v4 => v3}/usage.md | 0 mkdocs.yml | 16 ++++++++-------- 8 files changed, 8 insertions(+), 8 deletions(-) rename docs/book/{v4 => v3}/addingConfigProvider.md (100%) rename docs/book/{v4 => v3}/configuringWriter.md (100%) rename docs/book/{v4 => v3}/exampleWithFormatter.md (100%) rename docs/book/{v4 => v3}/filteringLogMessages.md (100%) rename docs/book/{v4 => v3}/formattingMessages.md (100%) rename docs/book/{v4 => v3}/groupingLogFilesByDate.md (100%) rename docs/book/{v4 => v3}/usage.md (100%) diff --git a/docs/book/v4/addingConfigProvider.md b/docs/book/v3/addingConfigProvider.md similarity index 100% rename from docs/book/v4/addingConfigProvider.md rename to docs/book/v3/addingConfigProvider.md diff --git a/docs/book/v4/configuringWriter.md b/docs/book/v3/configuringWriter.md similarity index 100% rename from docs/book/v4/configuringWriter.md rename to docs/book/v3/configuringWriter.md diff --git a/docs/book/v4/exampleWithFormatter.md b/docs/book/v3/exampleWithFormatter.md similarity index 100% rename from docs/book/v4/exampleWithFormatter.md rename to docs/book/v3/exampleWithFormatter.md diff --git a/docs/book/v4/filteringLogMessages.md b/docs/book/v3/filteringLogMessages.md similarity index 100% rename from docs/book/v4/filteringLogMessages.md rename to docs/book/v3/filteringLogMessages.md diff --git a/docs/book/v4/formattingMessages.md b/docs/book/v3/formattingMessages.md similarity index 100% rename from docs/book/v4/formattingMessages.md rename to docs/book/v3/formattingMessages.md diff --git a/docs/book/v4/groupingLogFilesByDate.md b/docs/book/v3/groupingLogFilesByDate.md similarity index 100% rename from docs/book/v4/groupingLogFilesByDate.md rename to docs/book/v3/groupingLogFilesByDate.md diff --git a/docs/book/v4/usage.md b/docs/book/v3/usage.md similarity index 100% rename from docs/book/v4/usage.md rename to docs/book/v3/usage.md diff --git a/mkdocs.yml b/mkdocs.yml index eecb239..44b767b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -2,18 +2,18 @@ docs_dir: docs/book site_dir: docs/html extra: project: Packages - current_version: v4 + current_version: v3 versions: - - v4 + - v3 nav: - Home: index.md - v4: - - "Adding The Config Provider": v4/addingConfigProvider.md - - "Configuring the writer(s)": v4/configuringWriter.md - - "Grouping log files by date": v4/groupingLogFilesByDate.md - - "Filtering log messages": v4/filteringLogMessages.md - - "Formatting Messages": v4/formattingMessages.md - - "Usage": v4/usage.md + - "Adding The Config Provider": v3/addingConfigProvider.md + - "Configuring the writer(s)": v3/configuringWriter.md + - "Grouping log files by date": v3/groupingLogFilesByDate.md + - "Filtering log messages": v3/filteringLogMessages.md + - "Formatting Messages": v3/formattingMessages.md + - "Usage": v3/usage.md site_name: dot-log site_description: "DotKernel log component extending and customizing" repo_url: "https://github.com/dotkernel/dot-log" From 7a5b4a6c64301e02d7f2a96e538eb6e852b8a1ed Mon Sep 17 00:00:00 2001 From: bidi Date: Mon, 1 Apr 2024 17:44:29 +0300 Subject: [PATCH 06/13] updated documentation --- mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs.yml b/mkdocs.yml index 44b767b..3dfc3fe 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -7,7 +7,7 @@ extra: - v3 nav: - Home: index.md - - v4: + - v3: - "Adding The Config Provider": v3/addingConfigProvider.md - "Configuring the writer(s)": v3/configuringWriter.md - "Grouping log files by date": v3/groupingLogFilesByDate.md From b04cc39d26859ac19d7b70e0acc6e917ecac54a1 Mon Sep 17 00:00:00 2001 From: bidi Date: Tue, 2 Apr 2024 12:09:19 +0300 Subject: [PATCH 07/13] updated documentation --- ...ingConfigProvider.md => adding-config-provider.md} | 0 .../{configuringWriter.md => configuring-writer.md} | 0 ...mpleWithFormatter.md => example-with-formatter.md} | 0 ...teringLogMessages.md => filtering-log-messages.md} | 0 .../{formattingMessages.md => formatting-messages.md} | 0 ...ogFilesByDate.md => grouping-log-files-by-date.md} | 0 mkdocs.yml | 11 ++++++----- 7 files changed, 6 insertions(+), 5 deletions(-) rename docs/book/v3/{addingConfigProvider.md => adding-config-provider.md} (100%) rename docs/book/v3/{configuringWriter.md => configuring-writer.md} (100%) rename docs/book/v3/{exampleWithFormatter.md => example-with-formatter.md} (100%) rename docs/book/v3/{filteringLogMessages.md => filtering-log-messages.md} (100%) rename docs/book/v3/{formattingMessages.md => formatting-messages.md} (100%) rename docs/book/v3/{groupingLogFilesByDate.md => grouping-log-files-by-date.md} (100%) diff --git a/docs/book/v3/addingConfigProvider.md b/docs/book/v3/adding-config-provider.md similarity index 100% rename from docs/book/v3/addingConfigProvider.md rename to docs/book/v3/adding-config-provider.md diff --git a/docs/book/v3/configuringWriter.md b/docs/book/v3/configuring-writer.md similarity index 100% rename from docs/book/v3/configuringWriter.md rename to docs/book/v3/configuring-writer.md diff --git a/docs/book/v3/exampleWithFormatter.md b/docs/book/v3/example-with-formatter.md similarity index 100% rename from docs/book/v3/exampleWithFormatter.md rename to docs/book/v3/example-with-formatter.md diff --git a/docs/book/v3/filteringLogMessages.md b/docs/book/v3/filtering-log-messages.md similarity index 100% rename from docs/book/v3/filteringLogMessages.md rename to docs/book/v3/filtering-log-messages.md diff --git a/docs/book/v3/formattingMessages.md b/docs/book/v3/formatting-messages.md similarity index 100% rename from docs/book/v3/formattingMessages.md rename to docs/book/v3/formatting-messages.md diff --git a/docs/book/v3/groupingLogFilesByDate.md b/docs/book/v3/grouping-log-files-by-date.md similarity index 100% rename from docs/book/v3/groupingLogFilesByDate.md rename to docs/book/v3/grouping-log-files-by-date.md diff --git a/mkdocs.yml b/mkdocs.yml index 3dfc3fe..050230a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -8,11 +8,12 @@ extra: nav: - Home: index.md - v3: - - "Adding The Config Provider": v3/addingConfigProvider.md - - "Configuring the writer(s)": v3/configuringWriter.md - - "Grouping log files by date": v3/groupingLogFilesByDate.md - - "Filtering log messages": v3/filteringLogMessages.md - - "Formatting Messages": v3/formattingMessages.md + - "Adding The Config Provider": v3/adding-config-provider.md + - "Configuring the writer(s)": v3/configuring-writer.md + - "Grouping log files by date": v3/grouping-log-files-by-date.md + - "Filtering log messages": v3/filtering-log-messages.md + - "Formatting Messages": v3/formatting-messages.md + - "Example with formatter": v3/example-with-formatter.md - "Usage": v3/usage.md site_name: dot-log site_description: "DotKernel log component extending and customizing" From 17e2978319e6faa7ad6125120fa196327ad09e5e Mon Sep 17 00:00:00 2001 From: bidi Date: Wed, 3 Apr 2024 18:05:07 +0300 Subject: [PATCH 08/13] updated workflows --- .github/workflows/continuous-integration.yml | 11 +++++ .github/workflows/cs-tests.yml | 47 -------------------- .github/workflows/static-analysis.yml | 47 -------------------- .github/workflows/unit-tests.yml | 47 -------------------- 4 files changed, 11 insertions(+), 141 deletions(-) create mode 100644 .github/workflows/continuous-integration.yml delete mode 100644 .github/workflows/cs-tests.yml delete mode 100644 .github/workflows/static-analysis.yml delete mode 100644 .github/workflows/unit-tests.yml diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 0000000..26c5802 --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,11 @@ +name: "Continuous Integration" + +on: + pull_request: + push: + branches: + tags: + +jobs: + ci: + uses: laminas/workflow-continuous-integration/.github/workflows/continuous-integration.yml@1.x diff --git a/.github/workflows/cs-tests.yml b/.github/workflows/cs-tests.yml deleted file mode 100644 index e8bbade..0000000 --- a/.github/workflows/cs-tests.yml +++ /dev/null @@ -1,47 +0,0 @@ -on: - - push - -name: Run phpcs checks - -jobs: - mutation: - name: PHP ${{ matrix.php }}-${{ matrix.os }} - - runs-on: ${{ matrix.os }} - - strategy: - matrix: - os: - - ubuntu-latest - - php: - - "8.1" - - "8.2" - - "8.3" - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install PHP - uses: shivammathur/setup-php@v2 - with: - php-version: "${{ matrix.php }}" - tools: composer:v2, cs2pr - coverage: none - - - name: Determine composer cache directory - run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV - - - name: Cache dependencies installed with composer - uses: actions/cache@v3 - with: - path: ${{ env.COMPOSER_CACHE_DIR }} - key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: | - php${{ matrix.php }}-composer- - - name: Install dependencies with composer - run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - - name: Run phpcs checks - run: vendor/bin/phpcs diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml deleted file mode 100644 index 6f7452d..0000000 --- a/.github/workflows/static-analysis.yml +++ /dev/null @@ -1,47 +0,0 @@ -on: - - push - -name: Run static analysis - -jobs: - mutation: - name: PHP ${{ matrix.php }}-${{ matrix.os }} - - runs-on: ${{ matrix.os }} - - strategy: - matrix: - os: - - ubuntu-latest - - php: - - "8.1" - - "8.2" - - "8.3" - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install PHP - uses: shivammathur/setup-php@v2 - with: - php-version: "${{ matrix.php }}" - tools: composer:v2, cs2pr - coverage: none - - - name: Determine composer cache directory - run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV - - - name: Cache dependencies installed with composer - uses: actions/cache@v3 - with: - path: ${{ env.COMPOSER_CACHE_DIR }} - key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: | - php${{ matrix.php }}-composer- - - name: Install dependencies with composer - run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - - name: Run static analysis - run: vendor/bin/psalm --no-cache --output-format=github --show-info=false --threads=4 diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml deleted file mode 100644 index 8f6f990..0000000 --- a/.github/workflows/unit-tests.yml +++ /dev/null @@ -1,47 +0,0 @@ -on: - - push - -name: Run PHPUnit tests - -jobs: - mutation: - name: PHP ${{ matrix.php }}-${{ matrix.os }} - - runs-on: ${{ matrix.os }} - - strategy: - matrix: - os: - - ubuntu-latest - - php: - - "8.1" - - "8.2" - - "8.3" - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install PHP - uses: shivammathur/setup-php@v2 - with: - php-version: "${{ matrix.php }}" - tools: composer:v2, cs2pr - coverage: none - - - name: Determine composer cache directory - run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV - - - name: Cache dependencies installed with composer - uses: actions/cache@v3 - with: - path: ${{ env.COMPOSER_CACHE_DIR }} - key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: | - php${{ matrix.php }}-composer- - - name: Install dependencies with composer - run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - - name: Run PHPUnit tests - run: vendor/bin/phpunit --colors=always From 425beba3601ee1ddf7a385a0ad2cc524c7252a95 Mon Sep 17 00:00:00 2001 From: bidi Date: Thu, 4 Apr 2024 12:55:09 +0300 Subject: [PATCH 09/13] updated composer.json --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f4e94ff..70cae91 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,8 @@ "config": { "sort-packages": true, "allow-plugins": { - "dealerdirect/phpcodesniffer-composer-installer": true + "dealerdirect/phpcodesniffer-composer-installer": true, + "laminas/laminas-dependency-plugin": false } }, "scripts": { From 5b0c609863f361e36a606e625c98f68e893f599b Mon Sep 17 00:00:00 2001 From: bidi Date: Thu, 4 Apr 2024 14:46:34 +0300 Subject: [PATCH 10/13] updated documentation --- docs/book/v3/adding-config-provider.md | 5 +++-- docs/book/v3/configuring-writer.md | 9 ++++++--- docs/book/v3/example-with-formatter.md | 7 +++---- docs/book/v3/filtering-log-messages.md | 7 ++----- docs/book/v3/formatting-messages.md | 7 ++----- docs/book/v3/grouping-log-files-by-date.md | 6 ++++-- docs/book/v3/usage.md | 6 ++++-- 7 files changed, 24 insertions(+), 23 deletions(-) diff --git a/docs/book/v3/adding-config-provider.md b/docs/book/v3/adding-config-provider.md index 8c73448..b3150eb 100644 --- a/docs/book/v3/adding-config-provider.md +++ b/docs/book/v3/adding-config-provider.md @@ -1,4 +1,5 @@ -## Adding The Config Provider +# Adding The Config Provider + * Enter config/config.php * If there is no entry for the config provider below, add it: `\Dot\Log\ConfigProvider::class` @@ -6,4 +7,4 @@ * Open the `Dot\Log\ConfigProvider` * In the dependencies section you will see an absctract factory (LoggerAbstractServiceFactory::class) * This class responds to "selectors" instead of class names - - Instead of requesting the `Laminas\Log\Logger::class`from the container, dot-log.my_logger should be requested (or just `my_logger` if using laminas-log) \ No newline at end of file + Instead of requesting the `Laminas\Log\Logger::class`from the container, dot-log.my_logger should be requested (or just `my_logger` if using laminas-log) diff --git a/docs/book/v3/configuring-writer.md b/docs/book/v3/configuring-writer.md index 68f2bee..4a05862 100644 --- a/docs/book/v3/configuring-writer.md +++ b/docs/book/v3/configuring-writer.md @@ -1,13 +1,16 @@ -## Configuring the writer(s) +# Configuring the writer(s) + Loggers must have at least one writer. A writer is an object that inherits from `Laminas\Log\Writer\AbstractWriter`. A writer's responsibility is to record log data to a storage backend. (from laminas-log's writer documentation) ### Writing to a file (stream) + It is possible separate logs into multiple files using writers and filters. For example *warnings.log*, *errors.log*, *all_messages.log*. The following is the simplest example to write all log messages to `/log/dk.log` + ```php return [ 'dot_log' => [ @@ -27,10 +30,10 @@ return [ ], ]; ``` + * The `FileWriter` key is optional, otherwise the writers array would be enumerative instead of associative. * The writer name key is a developer-provided name for that writer, the writer name key is **mandatory**. - The writer priority key is not affecting the errors that are written, it is a way to organize writers, for example: 1 - FILE @@ -40,4 +43,4 @@ It is the most important to write in the file, the sql or e-mail are more probab The writer priority key is optional. -To write into a file the key stream must be present in the writer options array. This is required only if writing into streams/files. \ No newline at end of file +To write into a file the key stream must be present in the writer options array. This is required only if writing into streams/files. diff --git a/docs/book/v3/example-with-formatter.md b/docs/book/v3/example-with-formatter.md index d301f84..58caf68 100644 --- a/docs/book/v3/example-with-formatter.md +++ b/docs/book/v3/example-with-formatter.md @@ -1,4 +1,4 @@ -### Example with formatter +# Example with formatter * The log is used through dot-log * The logger name is my_logger @@ -8,8 +8,6 @@ ```php [ 'loggers' => [ @@ -50,6 +48,7 @@ The messages are written to see which logs are written and which are not written use Laminas\Log\Logger; ``` ... + ```php $logger = $container->get('dot-log.my_logger'); @@ -63,4 +62,4 @@ $logger->notice('5 NOTICE'); $logger->info('6 INF'); $logger->debug('7 debug'); $logger->log(Logger::NOTICE, 'NOTICE from log()'); -``` \ No newline at end of file +``` diff --git a/docs/book/v3/filtering-log-messages.md b/docs/book/v3/filtering-log-messages.md index 8913967..c6860bf 100644 --- a/docs/book/v3/filtering-log-messages.md +++ b/docs/book/v3/filtering-log-messages.md @@ -1,4 +1,4 @@ -## Filtering log messages +# Filtering log messages As per PSR-3 document. @@ -6,7 +6,6 @@ The log levels are: emergency (0), alert (1), critical (2), error (3), warn (4), Although the plain Logger in Laminas Log is not fully compatible with PSR-3, it provides a way to log all of these message types. - The following example has three file writers using filters: * First Example: `FileWriter` - All messages are logged in `/log/dk.log` * Second Example: `OnlyWarningsWriter` - Only warnings are logged in `/log/warnings.log` @@ -87,6 +86,4 @@ The filter added on the first writer is equal to not setting a filter, but it wa It was added opposite to the others just to demonstrate the other operator is also an option. - - -More examples on filters: https://docs.laminas.dev/laminas-log/filters/ \ No newline at end of file +More examples on filters: https://docs.laminas.dev/laminas-log/filters/ diff --git a/docs/book/v3/formatting-messages.md b/docs/book/v3/formatting-messages.md index c0e2c6c..706877c 100644 --- a/docs/book/v3/formatting-messages.md +++ b/docs/book/v3/formatting-messages.md @@ -1,4 +1,4 @@ -## Formatting Messages +# Formatting Messages When using `dot-log` or `laminas-log`, the logged value is not limited to a string. Arrays can be logged as well. @@ -6,16 +6,13 @@ For a better readability, these arrays can be serialized. Laminas Log provides String formatting, XML, JSON and FirePHP formatting. - - The formatter accepts following parameters: name - the formatter class (it must implement Laminas\Log\Formatter\FormatterInterface) options - options to pass to the formatter constructor if required - The following formats the message as JSON data: 'formatter' => [ 'name' => \Laminas\Log\Formatter\Json::class, -], \ No newline at end of file +], diff --git a/docs/book/v3/grouping-log-files-by-date.md b/docs/book/v3/grouping-log-files-by-date.md index 17480af..6cf70b4 100644 --- a/docs/book/v3/grouping-log-files-by-date.md +++ b/docs/book/v3/grouping-log-files-by-date.md @@ -1,8 +1,10 @@ -## Grouping log files by date +# Grouping log files by date + By default, logs will be written to the same file: `log/dk.log`. Optionally, you can use date format specifiers wrapped between curly braces in your FileWriter's `stream` option, automatically grouping your logs by day, week, month, year etc. Examples: + * `log/dk-{Y}-{m}-{d}.log` will write every day to a different file (eg: log/dk-2021-01-01.log) * `log/dk-{Y}-{W}.log` will write every week to a different file (eg: log/dk-2021-10.log) -The full list of format specifiers is available [here](https://www.php.net/manual/en/datetime.format.php). \ No newline at end of file +The full list of format specifiers is available [here](https://www.php.net/manual/en/datetime.format.php). diff --git a/docs/book/v3/usage.md b/docs/book/v3/usage.md index f6c3a28..b297bf1 100644 --- a/docs/book/v3/usage.md +++ b/docs/book/v3/usage.md @@ -1,4 +1,5 @@ -## Usage +# Usage + Basic usage of the logger is illustraded below. The messages are written to see which logs are written and which are not written. @@ -6,6 +7,7 @@ The messages are written to see which logs are written and which are not written use Laminas\Log\Logger; ``` ... + ```php $logger = $container->get('dot-log.my_logger'); @@ -19,4 +21,4 @@ $logger->notice('5 NOTICE'); $logger->info('6 INF'); $logger->debug('7 debug'); $logger->log(Logger::NOTICE, 'NOTICE from log()'); -``` \ No newline at end of file +``` From d9ab25ec72437d7ec0766d621d0408ca61d89070 Mon Sep 17 00:00:00 2001 From: bidi Date: Thu, 4 Apr 2024 14:50:21 +0300 Subject: [PATCH 11/13] updated documentation --- docs/book/v3/configuring-writer.md | 2 +- docs/book/v3/example-with-formatter.md | 3 +++ docs/book/v3/filtering-log-messages.md | 1 + docs/book/v3/usage.md | 4 +++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/book/v3/configuring-writer.md b/docs/book/v3/configuring-writer.md index 4a05862..c76b6e9 100644 --- a/docs/book/v3/configuring-writer.md +++ b/docs/book/v3/configuring-writer.md @@ -4,7 +4,7 @@ Loggers must have at least one writer. A writer is an object that inherits from `Laminas\Log\Writer\AbstractWriter`. A writer's responsibility is to record log data to a storage backend. (from laminas-log's writer documentation) -### Writing to a file (stream) +## Writing to a file (stream) It is possible separate logs into multiple files using writers and filters. For example *warnings.log*, *errors.log*, *all_messages.log*. diff --git a/docs/book/v3/example-with-formatter.md b/docs/book/v3/example-with-formatter.md index 58caf68..fba6b85 100644 --- a/docs/book/v3/example-with-formatter.md +++ b/docs/book/v3/example-with-formatter.md @@ -41,12 +41,15 @@ return [ ``` ## Usage + Basic usage of the logger is illustraded below. The messages are written to see which logs are written and which are not written. + ```php use Laminas\Log\Logger; ``` + ... ```php diff --git a/docs/book/v3/filtering-log-messages.md b/docs/book/v3/filtering-log-messages.md index c6860bf..2e6326d 100644 --- a/docs/book/v3/filtering-log-messages.md +++ b/docs/book/v3/filtering-log-messages.md @@ -7,6 +7,7 @@ The log levels are: emergency (0), alert (1), critical (2), error (3), warn (4), Although the plain Logger in Laminas Log is not fully compatible with PSR-3, it provides a way to log all of these message types. The following example has three file writers using filters: + * First Example: `FileWriter` - All messages are logged in `/log/dk.log` * Second Example: `OnlyWarningsWriter` - Only warnings are logged in `/log/warnings.log` * Third Example: `WarningOrHigherWriter` - All important messages (`warnings` or more critical) are logged in `/log/important_messages.log` diff --git a/docs/book/v3/usage.md b/docs/book/v3/usage.md index b297bf1..fea781e 100644 --- a/docs/book/v3/usage.md +++ b/docs/book/v3/usage.md @@ -1,11 +1,13 @@ # Usage -Basic usage of the logger is illustraded below. +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; ``` + ... ```php From 059067c4cb6f07a71e292a4d3012ec503df54165 Mon Sep 17 00:00:00 2001 From: bidi Date: Thu, 4 Apr 2024 16:09:34 +0300 Subject: [PATCH 12/13] updated documentation --- README.md | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index ab2d6f7..6acd44f 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,6 @@ DotKernel log component extending and customizing [![SymfonyInsight](https://insight.symfony.com/projects/287e81e8-b4fb-4452-bd8f-4f12c0ab1f76/big.svg)](https://insight.symfony.com/projects/287e81e8-b4fb-4452-bd8f-4f12c0ab1f76) - ## Adding The Config Provider * Enter config/config.php * If there is no entry for the config provider below, add it: @@ -27,16 +26,18 @@ DotKernel log component extending and customizing - Instead of requesting the `Laminas\Log\Logger::class`from the container, dot-log.my_logger should be requested (or just `my_logger` if using laminas-log) ## Configuring the writer(s) + Loggers must have at least one writer. A writer is an object that inherits from `Laminas\Log\Writer\AbstractWriter`. A writer's responsibility is to record log data to a storage backend. (from laminas-log's writer documentation) - ### Writing to a file (stream) + It is possible separate logs into multiple files using writers and filters. For example *warnings.log*, *errors.log*, *all_messages.log*. The following is the simplest example to write all log messages to `/log/dk.log` + ```php return [ 'dot_log' => [ @@ -56,10 +57,10 @@ return [ ], ]; ``` + * The `FileWriter` key is optional, otherwise the writers array would be enumerative instead of associative. * The writer name key is a developer-provided name for that writer, the writer name key is **mandatory**. - The writer priority key is not affecting the errors that are written, it is a way to organize writers, for example: 1 - FILE @@ -71,7 +72,6 @@ The writer priority key is optional. To write into a file the key stream must be present in the writer options array. This is required only if writing into streams/files. - ## Grouping log files by date By default, logs will be written to the same file: `log/dk.log`. Optionally, you can use date format specifiers wrapped between curly braces in your FileWriter's `stream` option, automatically grouping your logs by day, week, month, year etc. @@ -81,7 +81,6 @@ Examples: The full list of format specifiers is available [here](https://www.php.net/manual/en/datetime.format.php). - ## Filtering log messages As per PSR-3 document. @@ -90,8 +89,8 @@ The log levels are: emergency (0), alert (1), critical (2), error (3), warn (4), Although the plain Logger in Laminas Log is not fully compatible with PSR-3, it provides a way to log all of these message types. - The following example has three file writers using filters: + * First Example: `FileWriter` - All messages are logged in `/log/dk.log` * Second Example: `OnlyWarningsWriter` - Only warnings are logged in `/log/warnings.log` * Third Example: `WarningOrHigherWriter` - All important messages (`warnings` or more critical) are logged in `/log/important_messages.log` @@ -171,8 +170,6 @@ The filter added on the first writer is equal to not setting a filter, but it wa It was added opposite to the others just to demonstrate the other operator is also an option. - - More examples on filters: https://docs.laminas.dev/laminas-log/filters/ ## Formatting Messages @@ -183,21 +180,17 @@ For a better readability, these arrays can be serialized. Laminas Log provides String formatting, XML, JSON and FirePHP formatting. - - The formatter accepts following parameters: name - the formatter class (it must implement Laminas\Log\Formatter\FormatterInterface) options - options to pass to the formatter constructor if required - The following formats the message as JSON data: 'formatter' => [ 'name' => \Laminas\Log\Formatter\Json::class, ], - ### Example with formatter * The log is used through dot-log @@ -243,13 +236,17 @@ return [ ``` ## Usage + Basic usage of the logger is illustraded below. The messages are written to see which logs are written and which are not written. + ```php use Laminas\Log\Logger; ``` + ... + ```php $logger = $container->get('dot-log.my_logger'); @@ -266,9 +263,9 @@ $logger->log(Logger::NOTICE, 'NOTICE from log()'); ``` Sources: + * https://docs.laminas.dev/laminas-log/ * https://docs.laminas.dev/laminas-log/writers/ * https://docs.laminas.dev/laminas-log/filters/ Extracted from [this article](https://www.dotkernel.com/dotkernel/logging-with-dot-log-in-mezzio-and-dotkernel) - From 61a39520b34cf1d74e7e90d8b61a5ca5520993e2 Mon Sep 17 00:00:00 2001 From: bidi Date: Thu, 4 Apr 2024 16:12:26 +0300 Subject: [PATCH 13/13] updated documentation --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6acd44f..3ce5269 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ DotKernel log component extending and customizing [![SymfonyInsight](https://insight.symfony.com/projects/287e81e8-b4fb-4452-bd8f-4f12c0ab1f76/big.svg)](https://insight.symfony.com/projects/287e81e8-b4fb-4452-bd8f-4f12c0ab1f76) ## Adding The Config Provider + * Enter config/config.php * If there is no entry for the config provider below, add it: `\Dot\Log\ConfigProvider::class` @@ -23,7 +24,7 @@ DotKernel log component extending and customizing * Open the `Dot\Log\ConfigProvider` * In the dependencies section you will see an absctract factory (LoggerAbstractServiceFactory::class) * This class responds to "selectors" instead of class names - - Instead of requesting the `Laminas\Log\Logger::class`from the container, dot-log.my_logger should be requested (or just `my_logger` if using laminas-log) + Instead of requesting the `Laminas\Log\Logger::class`from the container, dot-log.my_logger should be requested (or just `my_logger` if using laminas-log) ## Configuring the writer(s) @@ -73,9 +74,11 @@ The writer priority key is optional. To write into a file the key stream must be present in the writer options array. This is required only if writing into streams/files. ## Grouping log files by date + By default, logs will be written to the same file: `log/dk.log`. Optionally, you can use date format specifiers wrapped between curly braces in your FileWriter's `stream` option, automatically grouping your logs by day, week, month, year etc. Examples: + * `log/dk-{Y}-{m}-{d}.log` will write every day to a different file (eg: log/dk-2021-01-01.log) * `log/dk-{Y}-{W}.log` will write every week to a different file (eg: log/dk-2021-10.log)