예제 #1
0
/**
 * Class ErrorLogger
 */
class ErrorLogger extends Logger
{
    /**
     * @param $message
     * @return mixed|void
     */
    protected function doLog($message)
    {
        echo "Sending to stderr: ", $message, " \n";
    }
}
/**
 * Class StdoutLogger
 */
class StdoutLogger extends Logger
{
    /**
     * @param $message
     * @return mixed|void
     */
    protected function doLog($message)
    {
        echo "Writing to stdout: ", $message, " \n";
    }
}
$logger = new StdoutLogger();
$logger->setNext(new ErrorLogger())->setNext(new EmailLogger());
$logger->log('Something happened');
예제 #2
0
파일: index.php 프로젝트: Gnastw/CoursYNov
<?php

header('Content-Type: text/html; charset=utf-8');
require 'Logger.php';
require 'EmailLogger.php';
require 'ErrorLogger.php';
require 'StdoutLogger.php';
$logger = new StdoutLogger();
$logger->setNext(new ErrorLogger())->setNext(new EmailLogger());
$logger->log('Quelque chose se passe !');