Skip to content
Snippets Groups Projects
Commit 6720d757 authored by Hoop, Bert Jan de's avatar Hoop, Bert Jan de
Browse files

L05DOCBST-38 always return this in LoggerTrait

parent 66d7b8ed
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,7 @@ trait LoggerTrait {
/**
* set logger to send log messages to
* @param \Psr\Log\LoggerInterface $logger
* @return $this
*/
public function set_logger(\Psr\Log\LoggerInterface $logger) {
......@@ -40,73 +41,77 @@ trait LoggerTrait {
* debug message
* @param string $message
* @param array $context if not set the ndc is used
* @return type
* @return $this
*/
public function debug(string $message, array $context = null) {
if (!isset($this->logger)) {
return;
if (isset($this->logger)) {
$this->logger->debug($message, isset($context) ? $context : $this->ndc_context);
}
$this->logger->debug($message, isset($context) ? $context : $this->ndc_context);
return $this;
}
/**
* info message
* @param string $message
* @param array $context if not set the ndc is used
* @return type
* @return $this
*/
public function info(string $message, array $context = null) {
if (!isset($this->logger)) {
return;
if (isset($this->logger)) {
$this->logger->info($message, isset($context) ? $context : $this->ndc_context);
}
$this->logger->info($message, isset($context) ? $context : $this->ndc_context);
return $this;
}
/**
* warning message
* @param string $message
* @param array $context if not set the ndc is used
* @return type
* @return $this
*/
public function warning(string $message, array $context = null) {
if (!isset($this->logger)) {
return;
if (isset($this->logger)) {
$this->logger->warning($message, isset($context) ? $context : $this->ndc_context);
}
$this->logger->warning($message, isset($context) ? $context : $this->ndc_context);
return $this;
}
/**
* error message
* @param string $message
* @param array $context if not set the ndc is used
* @return type
* @return $this
*/
public function error(string $message, array $context = null) {
if (!isset($this->logger)) {
return;
if (isset($this->logger)) {
$this->logger->error($message, isset($context) ? $context : $this->ndc_context);
}
$this->logger->error($message, isset($context) ? $context : $this->ndc_context);
return $this;
}
/**
* add message to the ndc (nested diagnostic context)
* @param string $message
* @return $this
*/
public function ndc_push(string $message){
array_push($this->ndc_context, $message);
return $this;
}
/**
* remove last message from the ndc (nested diagnostic context)
* @return $this
*/
public function ndc_pop(){
array_pop($this->ndc_context);
return $this;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment