for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/**
* Balloon
*
* @author Raffael Sahli <[email protected]>
* @copyright Copryright (c) 2012-2017 gyselroth GmbH (https://gyselroth.com)
* @license GPL-3.0 https://opensource.org/licenses/GPL-3.0
*/
namespace Micro\Log\Adapter;
use Micro\Log\Exception;
abstract class AbstractAdapter implements AdapterInterface
{
* Log format.
* @var string
protected $format = '{date} {message}';
* Date format.
protected $date_format = 'Y-d-m H:i:s';
* Level.
* @var int
protected $level = 7;
* Create adapter.
public function __construct(? Iterable $config = null)
$this->setOptions($config);
}
* Get format.
* @return string
public function getFormat(): string
return $this->format;
* Get date format.
public function getDateFormat(): string
return $this->date_format;
* Get level.
* @return int
public function getLevel(): int
return $this->level;
* Set options.
* @return AdapterInterface
public function setOptions(? Iterable $config = null): AdapterInterface
if (null === $config) {
return $this;
foreach ($config as $option => $value) {
switch ($option) {
case 'date_format':
case 'format':
$this->{$option} = (string) $value;
break;
case 'level':
if (!is_numeric($value)) {
throw new Exception('log level must be a number');
$this->level = (int) $value;
default:
throw new Exception('invalid option '.$option.' given');