fresh/src/State/Log.php

39 lines
725 B
PHP

<?php
namespace NoccyLabs\FreshDocker\State;
class Log
{
private bool $verbose = false;
private array $log = [];
public function __construct(bool $verbose=false)
{
$this->verbose = $verbose;
}
public function setVerbose(bool $verbose)
{
$this->verbose = $verbose;
}
public function append(string $message)
{
array_push($this->log, $message);
if ($this->verbose) {
fwrite(STDOUT, $message . "\n");
}
}
public function flush()
{
if ($this->verbose) return;
fwrite(STDOUT, join("\n", $this->log)."\n");
}
public function asString(): string
{
return join("\n", $this->log);
}
}