1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-06 05:07:36 +02:00

Improved formatting

This commit is contained in:
Christophe Coevoet
2011-08-29 20:49:29 +02:00
parent 883d91d782
commit d746850316
2 changed files with 15 additions and 4 deletions

View File

@@ -47,8 +47,13 @@ class PDOHandler extends AbstractProcessingHandler
private function initialize()
{
$this->pdo->exec('CREATE TABLE IF NOT EXISTS monolog (channel VARCHAR(255), level INTEGER, message LONGTEXT, time INTEGER UNSIGNED)');
$this->statement = $this->pdo->prepare('INSERT INTO monolog (channel, level, message, time) VALUES (:channel, :level, :message, :time)');
$this->pdo->exec(
'CREATE TABLE IF NOT EXISTS monolog '
.'(channel VARCHAR(255), level INTEGER, message LONGTEXT, time INTEGER UNSIGNED)'
);
$this->statement = $this->pdo->prepare(
'INSERT INTO monolog (channel, level, message, time) VALUES (:channel, :level, :message, :time)'
);
}
}
```
@@ -66,4 +71,4 @@ $logger->addInfo('My logger is now ready');
The `Monolog\Handler\AbstractProcessingHandler` class provides most of the
logic needed for the handler, including the use of processors and the formatting
of the record (which is why we use ``$record['formatted']`` instead of ``$record['message']``.
of the record (which is why we use ``$record['formatted']`` instead of ``$record['message']``).

View File

@@ -50,7 +50,10 @@ Adding extra data in the records
Monolog provides two different ways to add extra informations along the simple
textual message.
The first one is the context, allowing to pass an array of data along the
Using the logging context
~~~~~~~~~~~~~~~~~~~~~~~~~
The first way is the context, allowing to pass an array of data along the
record:
```php
@@ -63,6 +66,9 @@ Simple handlers (like the StreamHandler for instance) will simply format
the array to a string but richer handlers can take advantage of the context
(FirePHP is able to display arrays in pretty way for instance).
Using processors
~~~~~~~~~~~~~~~~
The second way is to add extra data for all records by using a processor.
Processors can be any callable. They will get the record as parameter and
must return it after having eventually changed the `extra` part of it. Let's