for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types = 1);
/**
* Micro
*
* @author Raffael Sahli <[email protected]>
* @copyright Copyright (c) 2017 gyselroth GmbH (https://gyselroth.com)
* @license MIT https://opensource.org/licenses/MIT
*/
namespace Micro\Log\Adapter;
class File extends AbstractAdapter
{
* Filename
* @var string
protected $file = '/tmp/out.log';
* @var resource
protected $resource;
* Set options
* @return AdapterInterface
public function setOptions(? Iterable $config = null) : AdapterInterface
if ($config === null) {
$this->resource = fopen($this->file, 'a');
return $this;
}
foreach ($config as $option => $value) {
switch ($option) {
case 'file':
$this->file = str_replace('APPLICATION_PATH', APPLICATION_PATH, (string)$value);
unset($config[$option]);
break;
parent::setOptions($config);
* Log
* @param int $priority
* @param string $message
* @return bool
public function log(string $priority, string $message): bool
if (!is_resource($this->resource)) {
return false;
$result = fwrite($this->resource, $message."\n");
return (bool)$result;