Documentation

Log
in package

Table of Contents

Constants

DEFAULT_CHANNEL  : mixed = 'wsc'
Default channel name for WSC logs.
SENTRY_THROTTLE_SECONDS  : mixed = 60
One Sentry event per failure shape per minute, network-wide.

Methods

error()  : void
Logs an error message to the "wsc" logging channel and reports it to Sentry.
exception()  : void
Logs an exception to the "wsc" logging channel, including its message, stack trace, and code.
info()  : void
Logs an informational message to the "wsc" logging channel.
stackTrace()  : void|string
Logs the current stack trace (non-error based).
warning()  : void
Logs a warning message to the "wsc" logging channel.
acornReady()  : bool
Whether the Laravel log facade is actually usable.
capture()  : void
Reports a handled failure to Sentry, if Sentry is configured and not throttled.
claimThrottleSlot()  : bool
Takes this failure shape's slot for the throttle window, or reports it as taken.
executionContext()  : string
Where the failure happened, so a frontend degradation is distinguishable from a failed populate in Sentry.
messageShape()  : string
Collapses a log message to its shape, dropping the parts that vary per item.
sentryReady()  : bool
Whether a Sentry client is actually available to send to.
write()  : void
Writes one line to the file log, or to error_log() when Acorn is not there to take it.
writeError()  : void
Writes an error line to the log file without reporting it to Sentry.

Constants

DEFAULT_CHANNEL

Default channel name for WSC logs.

public mixed DEFAULT_CHANNEL = 'wsc'

SENTRY_THROTTLE_SECONDS

One Sentry event per failure shape per minute, network-wide.

private mixed SENTRY_THROTTLE_SECONDS = 60

A dead TypeSense fails on every collection read of all twelve sites, so an unthrottled bridge would spend the whole Sentry quota on a single incident. Same reasoning — and same transient mechanism — as TsHealth's log throttle.

Methods

error()

Logs an error message to the "wsc" logging channel and reports it to Sentry.

public static error(string $message[, string $channel = self::DEFAULT_CHANNEL ]) : void
Parameters
$message : string

The message to be logged at the error level.

$channel : string = self::DEFAULT_CHANNEL

Optional custom channel name.

exception()

Logs an exception to the "wsc" logging channel, including its message, stack trace, and code.

public static exception(Throwable $exception[, string $message = '' ][, string $channel = self::DEFAULT_CHANNEL ]) : void

The file log keeps its seven-line block; Sentry gets the Throwable itself, once, so the stack trace is structured rather than a string.

Parameters
$exception : Throwable

The exception to be logged.

$message : string = ''

Additional message to log with the exception.

$channel : string = self::DEFAULT_CHANNEL

Optional custom channel name.

info()

Logs an informational message to the "wsc" logging channel.

public static info(string $message[, string $channel = self::DEFAULT_CHANNEL ]) : void
Parameters
$message : string

The message to be logged at the informational level.

$channel : string = self::DEFAULT_CHANNEL

Optional custom channel name.

stackTrace()

Logs the current stack trace (non-error based).

public static stackTrace([string|null $label = null ][, bool $asString = false ][, string $channel = self::DEFAULT_CHANNEL ]) : void|string

Useful for debugging purposes to trace function/method calls without triggering exceptions. Optionally accepts a label to prefix the trace output for clarity.

Parameters
$label : string|null = null

Optional label to include in the log

$asString : bool = false

If true, returns the stack trace as string instead of logging it

$channel : string = self::DEFAULT_CHANNEL
Return values
void|string

warning()

Logs a warning message to the "wsc" logging channel.

public static warning(string $message[, string $channel = self::DEFAULT_CHANNEL ][, bool $notify = false ]) : void

Warnings stay file-only by default: a missing banner, an award absent from PIM or a rejected webhook secret are routine and would drown the real signal in Sentry. Pass $notify for the rare warning that is genuinely worth waking someone for, such as TsHealth opening the breaker on all sites.

Parameters
$message : string

The message to be logged at the warning level.

$channel : string = self::DEFAULT_CHANNEL

Optional custom channel name.

$notify : bool = false

Whether to also report this warning to Sentry.

acornReady()

Whether the Laravel log facade is actually usable.

private static acornReady() : bool

Mirrors sentryReady(): a cheap symbol check first, then ask the runtime whether it is booted. Both stages are load-bearing — class_exists() is false when the theme autoloader was never registered, and the facade-root check catches the narrower case where Illuminate is autoloadable but no application is bound to it.

Return values
bool

capture()

Reports a handled failure to Sentry, if Sentry is configured and not throttled.

private static capture(string $shape, string $channel, Throwable|null $exception, string $message, string $level) : void
Parameters
$shape : string

Stable identity of the failure, for grouping and throttling.

$channel : string

WSC log channel the failure was filed under.

$exception : Throwable|null

The Throwable to report, when there is one.

$message : string

Message to report when there is no Throwable.

$level : string

Sentry severity: "error" or "warning".

claimThrottleSlot()

Takes this failure shape's slot for the throttle window, or reports it as taken.

private static claimThrottleSlot(string $shape) : bool

Site transients so the window is shared by all twelve sites and both web and CLI.

Parameters
$shape : string
Return values
bool

executionContext()

Where the failure happened, so a frontend degradation is distinguishable from a failed populate in Sentry.

private static executionContext() : string
Return values
string

messageShape()

Collapses a log message to its shape, dropping the parts that vary per item.

private static messageShape(string $message) : string

"Error deleting collection "products_en_gb_1712"" and its thousand siblings have to group as one failure, not one issue per collection.

Parameters
$message : string
Return values
string

sentryReady()

Whether a Sentry client is actually available to send to.

private static sentryReady() : bool

Read off the hub rather than the wp-sentry tracker: the hub answers without constructing anything, so a DSN-less environment (local, CI) stays a true no-op.

Return values
bool

write()

Writes one line to the file log, or to error_log() when Acorn is not there to take it.

private static write(string $level, string $message, string $channel) : void

Every FacadesLog touch point funnels through here. Illuminate ships with the THEME's vendor dir, not the connector's, so on any request that never boots Acorn (wp-admin/install.php, an early-hook fatal) the facade is not merely unbound — the class does not autoload at all. Calling it there turned a handled TypeSense failure into an uncaught one, which is the opposite of what this class is for.

Parameters
$level : string
$message : string
$channel : string

writeError()

Writes an error line to the log file without reporting it to Sentry.

private static writeError(string $message, string $channel) : void

exception() emits seven lines per call; routing each through error() would file seven Sentry events for one failure.

Parameters
$message : string
$channel : string
On this page

Search results