Logger

Extends \Psr\Log\AbstractLogger

Class Logger

This is only the Wrapper for a PSR Logger and not the actual Logger. Implements some convenience functions for better logging.

package

NextEvent\PHPSDK\Util

Methods

Logger constructor. Wrap given Logger with defaultContext functionality.

__construct(\Psr\Log\LoggerInterface $logger = null) 

If no logger defined, provide mock replacement with void functions.

Arguments

$logger

\Psr\Log\LoggerInterface

Getter for the wrapped Logger instance

getLogger() : \Psr\Log\LoggerInterface|null

Response

\Psr\Log\LoggerInterface|null

Logs with the given level

log(mixed $level, string $message, array $context = array()) : void

Arguments

$level

mixed

$message

string

$context

array

Define which values should be used as default for the context

setDefaultContext(array $defaultContext = array()) : $this

Arguments

$defaultContext

array

Response

$this

Make sure the logger is properly wrapped and can be used with defaultContext.

wrapLogger(\Psr\Log\LoggerInterface $logger = null, array $defaultContext = array()) : \NextEvent\PHPSDK\Util\Log\Logger
static

If no logger given, use logger mock.

Throws
\NextEvent\PHPSDK\Exception\InvalidArgumentException

Arguments

$logger

\Psr\Log\LoggerInterface

$defaultContext

array

Response

\NextEvent\PHPSDK\Util\Log\Logger