Logging

The skeleton app comes with a PSR-3 compliant logger that you can replace or remove if you want.

The logger is defined in the dependencies.php file.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<?php
use Vespula\Log\Log as Logger;
use Vespula\Log\Adapter\ErrorLog;

$container['log'] = function () {
    // Log to PHP's default logger (if error_log set in ini)
    $adapter = new ErrorLog(ErrorLog::TYPE_PHP_LOG);
    $log = new Logger($adapter);
    return $log;
};

Below is a simple example of usage in a controller. Note you access the logger via $this->log

1
2
3
<?php
$this->log->warning('This is a warning message');
$this->log->info('This is informative');

Where the log outputs data is up to you. You define the adapter in your dependencies file. See the Vespula/Log documentation.