Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get log destination Add check log empty #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/Logger/AbstractLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ abstract class AbstractLogger extends PsrAbstractLogger
*/
protected $options = array();

/**
* Whether or not log is empty.
* @var bool
*/
protected $empty = true;

/**
* Gets the named level code.
*
Expand Down Expand Up @@ -111,6 +117,10 @@ public function log($level, Stringable|string $message, array $context = array()
*/
public function process(LogEntry $log)
{
if ($this->empty) {
$this->empty = false;
}

if ($this->deferred) {
$this->deferred_logs[] = $log;
} else {
Expand Down Expand Up @@ -276,7 +286,7 @@ public function setLogFormatter(LogFormatter $formatter)
* @return LogFormatter
*/
public function getLogFormatter()
{
{
if(!$this->log_formatter) {
$this->setLogFormatter(new LogFormatter);
}
Expand All @@ -296,4 +306,13 @@ public function setOptions(array $options=null)
}
}

}
/**
* Check if log is empty
*
* @return bool
*/
public function isEmpty() : bool
{
return $this->empty;
}
}
11 changes: 10 additions & 1 deletion src/Logger/ErrorLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,13 @@ public function write(LogEntry $log)
);
}

}
/**
* Get log destination
*
* @return string|null
*/
public function getDestination() : string|null
{
return $this->destination;
}
}
2 changes: 0 additions & 2 deletions src/Logger/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/
class File extends ErrorLog
{

/**
* Constructor.
*
Expand All @@ -42,5 +41,4 @@ public function __construct($file)
$this->destination = $file;
$this->type = static::FILE;
}

}