<?php
/**
* FileLoggerStrategy file
*
* Copyright (c) 2016, Kiril Savchev
* All rights reserved.
*
* @category Libs
* @package Logger
*
* @author Kiril Savchev <k.savchev@gmail.com>
*
* @license https://opensource.org/licenses/BSD-3-Clause BSD 3 License
* @link http://ifthenelse.info
*/
namespace Ite\Logger\Stream\Strategy;
use Ite\Logger\Exception\InvalidArgumentException;
use Ite\Logger\FileLogger;
use Psr\Log\LoggerInterface;
/**
* FileLoggerStrategy
*
* Simple strategy preparation for FileLoggers
*
* @uses psr\log
*
* @version 1.0
*
* @author Kiril Savchev <k.savchev@gmail.com>
*/
class FileLoggerStrategy implements StreamLoggerStrategyInterface {
/**
* Prepare the logger before using
*
* @param LoggerInterface $logger
* @param array $options
* @throw \Ite\Logger\Exception\InvalidArgumentException If logger is not the desired class instance
*/
public function prepareLogger(LoggerInterface $logger, array $options) {
if (!($logger instanceof FileLogger)) {
throw new InvalidArgumentException("Invalid logger type");
}
/* @var $logger \Ite\Logger\FileLogger */
if (array_key_exists('log', $options)) {
$logger->setDefaultLog($options['log']);
}
}
}
|