\MonologErrorHandler

Monolog error handler

A facility to enable logging of runtime errors, exceptions and fatal errors.

Quick setup: ErrorHandler::register($logger);

Summary

Methods
Properties
Constants
__construct()
register()
registerExceptionHandler()
registerErrorHandler()
registerFatalHandler()
handleError()
handleFatalError()
No public properties found
No constants found
defaultExceptionLevelMap()
defaultErrorLevelMap()
No protected properties found
N/A
handleException()
codeToString()
$logger
$previousExceptionHandler
$uncaughtExceptionLevelMap
$previousErrorHandler
$errorLevelMap
$handleOnlyReportedErrors
$hasFatalErrorHandler
$fatalLevel
$reservedMemory
$lastFatalData
$fatalErrors
N/A

Properties

$previousExceptionHandler

$previousExceptionHandler : ?callable

Type

?callable

$uncaughtExceptionLevelMap

$uncaughtExceptionLevelMap

$previousErrorHandler

$previousErrorHandler : callable|true|null

Type

callable|true|null

$errorLevelMap

$errorLevelMap

$handleOnlyReportedErrors

$handleOnlyReportedErrors : bool

Type

bool

$hasFatalErrorHandler

$hasFatalErrorHandler : bool

Type

bool

$fatalLevel

$fatalLevel

$reservedMemory

$reservedMemory : ?string

Type

?string

$lastFatalData

$lastFatalData

$fatalErrors

$fatalErrors : int[]

Type

int[]

Methods

__construct()

__construct(\Psr\Log\LoggerInterface  $logger) : mixed

Parameters

\Psr\Log\LoggerInterface $logger

Returns

mixed —

register()

register(\Psr\Log\LoggerInterface  $logger, mixed  $errorLevelMap = [], mixed  $exceptionLevelMap = [], mixed  $fatalLevel = null) : \Monolog\ErrorHandler

Registers a new ErrorHandler for a given Logger

By default it will handle errors, exceptions and fatal errors

Parameters

\Psr\Log\LoggerInterface $logger
mixed $errorLevelMap
mixed $exceptionLevelMap
mixed $fatalLevel

Returns

\Monolog\ErrorHandler —

registerExceptionHandler()

registerExceptionHandler(array  $levelMap = [], bool  $callPrevious = true) : $this

Parameters

array $levelMap
bool $callPrevious

Returns

$this —

registerErrorHandler()

registerErrorHandler(array  $levelMap = [], bool  $callPrevious = true, int  $errorTypes = -1, bool  $handleOnlyReportedErrors = true) : $this

Parameters

array $levelMap
bool $callPrevious
int $errorTypes
bool $handleOnlyReportedErrors

Returns

$this —

registerFatalHandler()

registerFatalHandler(mixed  $level = null, int  $reservedMemorySize = 20) : self

Parameters

mixed $level
int $reservedMemorySize

Amount of KBs to reserve in memory so that it can be freed when handling fatal errors giving Monolog some room in memory to get its job done

Returns

self —

handleError()

handleError(int  $code, string  $message, string  $file = '', int  $line, array  $context = []) : bool

Parameters

int $code
string $message
string $file
int $line
array $context

Returns

bool —

handleFatalError()

handleFatalError() : void

defaultExceptionLevelMap()

defaultExceptionLevelMap() : array

Returns

array —

defaultErrorLevelMap()

defaultErrorLevelMap() : array

Returns

array —

handleException()

handleException(\Throwable  $e) : void

Parameters

\Throwable $e

codeToString()

codeToString(int  $code) : string

Parameters

int $code

Returns

string —