diff --git a/doc/extending.md b/doc/extending.md index 9db481a8..322d256e 100644 --- a/doc/extending.md +++ b/doc/extending.md @@ -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']``). diff --git a/doc/usage.md b/doc/usage.md index 45694d88..f8509d50 100644 --- a/doc/usage.md +++ b/doc/usage.md @@ -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