bradleyhodges/api-manager

ErrorLogger
in package

ErrorLogger class that standardizes error logging with detailed information.

It uses the Monolog library to log errors to a specified file.

Table of Contents

Methods

__construct()  : mixed
ErrorLogger constructor.
logCritical()  : void
Logs a critical error. Can accept either a string message or a Throwable.
logError()  : void
Logs an error with detailed information including file, line, message, and optional trace.
logInfo()  : void
Logs an info-level message for general application info.

Methods

__construct()

ErrorLogger constructor.

public __construct([string $logFile = '/var/log/caddy/phpApiManager.log' ]) : mixed

Initializes the Monolog logger with a file handler and custom formatting.

Parameters
$logFile : string = '/var/log/caddy/phpApiManager.log'

The file path where logs will be written.

logCritical()

Logs a critical error. Can accept either a string message or a Throwable.

public logCritical(string|Throwable $error) : void
Parameters
$error : string|Throwable

The error to log, either as a message or an exception.

logError()

Logs an error with detailed information including file, line, message, and optional trace.

public logError(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
$message : string

The error message to log.

$context : array<string|int, mixed> = []

Optional additional context (e.g., exception trace).

logInfo()

Logs an info-level message for general application info.

public logInfo(string $message) : void
Parameters
$message : string

The informational message to log.


        
On this page

Search results