Multiple Adapters

You may want more than one log adapter. For example, one that logs everything above INFO to a file, and one that only logs CRITICAL and higher to email.

<?php
use Vespula\Log\Log;
use Vespula\Log\Adapter\Email as EmailAdapter;
use Vespula\Log\Adapter\File as FileAdapter;
use Psr\Log\LogLevel;

$file_adapter = new FileAdapter('/path/to/log.txt');
$file_adapter->setMinLevel(LogLevel::INFO); // Debug won't be logged

$to = 'me@example.com';
$from = 'do-not-reply@example.com';
$subject = 'MyApp Log';

$emailAdapter = new EmailAdapter($to, $from, $subject);

$emailAdapter->setMinLevel(LogLevel::CRITICAL); //CRITICAL and higher will be logged by email

$log = new Log('file', $file_adapter); //default adapter
$log->addAdapter('email', $emailAdapter);

$log->alert('This is really bad'); // Goes to both adapters
$log->warning('This is not too horrible'); // only logged in the file.