Skip to content

Commit

Permalink
updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
bidi47 committed Apr 4, 2024
1 parent 425beba commit 5b0c609
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 23 deletions.
5 changes: 3 additions & 2 deletions docs/book/v3/adding-config-provider.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
## 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`
* 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)
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)
9 changes: 6 additions & 3 deletions docs/book/v3/configuring-writer.md
Original file line number Diff line number Diff line change
@@ -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)

Check failure on line 7 in docs/book/v3/configuring-writer.md

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Documentation Linting [8.1, latest], ubuntu-latest, laminas/laminas-continuous-integra...

Heading levels should only increment by one level at a time [Expected: h2; Actual: h3]

Check failure on line 7 in docs/book/v3/configuring-writer.md

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Documentation Linting [8.1, latest], ubuntu-latest, laminas/laminas-continuous-integra...

Heading levels should only increment by one level at a time [Expected: h2; Actual: h3]

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' => [
Expand All @@ -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
Expand All @@ -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.
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.
7 changes: 3 additions & 4 deletions docs/book/v3/example-with-formatter.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### Example with formatter
# Example with formatter

* The log is used through dot-log
* The logger name is my_logger
Expand All @@ -8,8 +8,6 @@

```php
<?php


return [
'dot_log' => [
'loggers' => [
Expand Down Expand Up @@ -50,6 +48,7 @@ The messages are written to see which logs are written and which are not written
use Laminas\Log\Logger;
```

Check failure on line 49 in docs/book/v3/example-with-formatter.md

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Documentation Linting [8.1, latest], ubuntu-latest, laminas/laminas-continuous-integra...

Fenced code blocks should be surrounded by blank lines [Context: "```"]

Check failure on line 49 in docs/book/v3/example-with-formatter.md

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Documentation Linting [8.1, latest], ubuntu-latest, laminas/laminas-continuous-integra...

Fenced code blocks should be surrounded by blank lines [Context: "```"]
...

```php
$logger = $container->get('dot-log.my_logger');

Expand All @@ -63,4 +62,4 @@ $logger->notice('5 NOTICE');
$logger->info('6 INF');
$logger->debug('7 debug');
$logger->log(Logger::NOTICE, 'NOTICE from log()');
```
```
7 changes: 2 additions & 5 deletions docs/book/v3/filtering-log-messages.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
## Filtering log messages
# 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`

Check failure on line 10 in docs/book/v3/filtering-log-messages.md

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Documentation Linting [8.1, latest], ubuntu-latest, laminas/laminas-continuous-integra...

Lists should be surrounded by blank lines [Context: "* First Example: `FileWriter` ..."]

Check failure on line 10 in docs/book/v3/filtering-log-messages.md

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Documentation Linting [8.1, latest], ubuntu-latest, laminas/laminas-continuous-integra...

Lists should be surrounded by blank lines [Context: "* First Example: `FileWriter` ..."]
* Second Example: `OnlyWarningsWriter` - Only warnings are logged in `/log/warnings.log`
Expand Down Expand Up @@ -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/
More examples on filters: https://docs.laminas.dev/laminas-log/filters/
7 changes: 2 additions & 5 deletions docs/book/v3/formatting-messages.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
## 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.

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,
],
],
6 changes: 4 additions & 2 deletions docs/book/v3/grouping-log-files-by-date.md
Original file line number Diff line number Diff line change
@@ -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).
The full list of format specifiers is available [here](https://www.php.net/manual/en/datetime.format.php).
6 changes: 4 additions & 2 deletions docs/book/v3/usage.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
## 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.
```php

Check failure on line 6 in docs/book/v3/usage.md

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Documentation Linting [8.1, latest], ubuntu-latest, laminas/laminas-continuous-integra...

Fenced code blocks should be surrounded by blank lines [Context: "```php"]

Check failure on line 6 in docs/book/v3/usage.md

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Documentation Linting [8.1, latest], ubuntu-latest, laminas/laminas-continuous-integra...

Fenced code blocks should be surrounded by blank lines [Context: "```php"]
use Laminas\Log\Logger;
```

Check failure on line 8 in docs/book/v3/usage.md

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Documentation Linting [8.1, latest], ubuntu-latest, laminas/laminas-continuous-integra...

Fenced code blocks should be surrounded by blank lines [Context: "```"]

Check failure on line 8 in docs/book/v3/usage.md

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Documentation Linting [8.1, latest], ubuntu-latest, laminas/laminas-continuous-integra...

Fenced code blocks should be surrounded by blank lines [Context: "```"]
...

```php
$logger = $container->get('dot-log.my_logger');

Expand All @@ -19,4 +21,4 @@ $logger->notice('5 NOTICE');
$logger->info('6 INF');
$logger->debug('7 debug');
$logger->log(Logger::NOTICE, 'NOTICE from log()');
```
```

0 comments on commit 5b0c609

Please sign in to comment.