<commit_before>
# Base collectors

Collectors provided in the `DebugBar\DataCollector` namespace.

## Messages

Provides a way to log messages (compatible with [PSR-3 logger](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)).

    $debugbar->addCollector(new DebugBar\DataCollector\MessagesCollector());
    $debugbar['messages']->info('hello world');

You can have multiple messages collector by naming them:

    $debugbar->addCollector(new MessagesCollector('io_ops'));
    $debugbar['io_ops']->info('opening files');

You can aggregate messages collector into other to have a unified view:

    $debugbar['messages']->aggregate($debugbar['io_ops']);

If you don't want to create a standalone tab in the debug bar but still be able
to log messages from a different collector, you don't have to add the collector
to the debug bar:

    $debugbar['messages']->aggregate(new MessagesCollector('io_ops'));

## TimeData

Provides a way to log total execution time as well as taking "measures" (ie. measure the execution time of a particular operation).

    $debugbar->addCollector(new DebugBar\DataCollector\TimeDataCollector());

    $debugbar['time']->startMeasure('longop', 'My long operation');
    sleep(2);
    $debugbar['time']->stopMeasure('longop');

    $debugbar['time']->measure('My long operation', function() {
        sleep(2);
    });

Displays the measures on a timeline

## Exceptions

Display exceptions

    $debugbar->addCollector(new DebugBar\DataCollector\ExceptionsCollector());

    try {
        throw new Exception('foobar');
    } catch (Exception $e) {
        $debugbar['exceptions']->addException($e);
    }

## PDO

Logs SQL queries. You need to wrap your `PDO` object into a `DebugBar\DataCollector\PDO\TraceablePDO` object.

    $pdo = new DebugBar\DataCollector\PDO\TraceablePDO(new PDO('sqlite::memory:'));
    $debugbar->addCollector(new DebugBar\DataCollector\PDO\PDOCollector($pdo));

You can even log queries from multiple `PDO` connections:

    $pdoRead  = new DebugBar\DataCollector\PDO\TraceablePDO(new PDO('sqlite::memory:'));
    $pdoWrite = new DebugBar\DataCollector\PDO\TraceablePDO(new PDO('sqlite::memory:'));

    $pdoCollector = new DebugBar\DataCollector\PDO\PDOCollector();
    $pdoCollector->addConnection($pdoRead, 'read-db');
    $pdoCollector->addConnection($pdoWrite, 'write-db');

    $debugbar->addCollector($pdoCollector);

## RequestData

Collects the data of PHP's global variables

    $debugbar->addCollector(new DebugBar\DataCollector\RequestDataCollector());

## Config

Used to display any key/value pairs array

    $data = array('foo' => 'bar');<commit_msg>Update docs for PDOConnector (#305)<commit_after>
# Base collectors

Collectors provided in the `DebugBar\DataCollector` namespace.

## Messages

Provides a way to log messages (compatible with [PSR-3 logger](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)).

    $debugbar->addCollector(new DebugBar\DataCollector\MessagesCollector());
    $debugbar['messages']->info('hello world');

You can have multiple messages collector by naming them:

    $debugbar->addCollector(new MessagesCollector('io_ops'));
    $debugbar['io_ops']->info('opening files');

You can aggregate messages collector into other to have a unified view:

    $debugbar['messages']->aggregate($debugbar['io_ops']);

If you don't want to create a standalone tab in the debug bar but still be able
to log messages from a different collector, you don't have to add the collector
to the debug bar:

    $debugbar['messages']->aggregate(new MessagesCollector('io_ops'));

## TimeData

Provides a way to log total execution time as well as taking "measures" (ie. measure the execution time of a particular operation).

    $debugbar->addCollector(new DebugBar\DataCollector\TimeDataCollector());

    $debugbar['time']->startMeasure('longop', 'My long operation');
    sleep(2);
    $debugbar['time']->stopMeasure('longop');

    $debugbar['time']->measure('My long operation', function() {
        sleep(2);
    });

Displays the measures on a timeline

## Exceptions

Display exceptions

    $debugbar->addCollector(new DebugBar\DataCollector\ExceptionsCollector());

    try {
        throw new Exception('foobar');
    } catch (Exception $e) {
        $debugbar['exceptions']->addException($e);
    }

## PDO

Logs SQL queries. You need to wrap your `PDO` object into a `DebugBar\DataCollector\PDO\TraceablePDO` object.

    $pdo = new DebugBar\DataCollector\PDO\TraceablePDO(new PDO('sqlite::memory:'));
    $debugbar->addCollector(new DebugBar\DataCollector\PDO\PDOCollector($pdo));

You can even log queries from multiple `PDO` connections:

    $pdoRead  = new DebugBar\DataCollector\PDO\TraceablePDO(new PDO('sqlite::memory:'));
    $pdoWrite = new DebugBar\DataCollector\PDO\TraceablePDO(new PDO('sqlite::memory:'));

    $pdoCollector = new DebugBar\DataCollector\PDO\PDOCollector();
    $pdoCollector->addConnection($pdoRead, 'read-db');
    $pdoCollector->addConnection($pdoWrite, 'write-db');

    $debugbar->addCollector($pdoCollector);
    
If you want to see your PDO requests in the TimeDataCollector, you must add the PDOConnector to the $debugbar _first_

    $timeDataCollector = new DebugBar\DataCollector\TimeDataCollector();
    $pdoCollector = new DebugBar\DataCollector\PDO\PDOCollector($pdo, $timeDataCollector);
    
    $debugBar->addCollector($pdoCollector);
    $debugBar->addCollector($timeDataCollector);

## RequestData

Collects the data of PHP's global variables

    $debugbar->addCollector(new DebugBar\DataCollector\RequestDataCollector());

## Config

Used to display any key/value pairs array

    $data = array('foo' => 'bar');
{'fraction_non_alphanumeric': 0.12865598885793872, 'fraction_numerical': 0.001915041782729805, 'mean_word_length': 4.82657200811359, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 41, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1743572', 'n_tokens_mistral': 1818, 'n_tokens_neox': 1747, 'n_words': 450}