LogChannel
final class LogChannel implements Channel
Notification channel that writes notifications to the application log.
This channel is useful for development or local environments where sending real notifications (e.g., email, SMS, Slack) is not desired. It serializes the notifiable entity and notification message into a JSON structure and writes it to the configured Logger.
Constants
| private CONTROL_KEYS |
The available control keys. |
Methods
Configures log array
Return the list of control keys that will be stripped from the data bag.
Build the consolidated "data" bag for logging.
Determine the human‑readable message to log.
Returns the canonical name of the channel.
Extract a string message from the payload, if present.
Send the given notification to the log.
Details
at line 34
static private array
configureLog(array $data, string $message, array $meta, string $notifiableClass, string $notificationClass)
Configures log array
at line 57
static private array
controlKeys()
| internal | Exposed for testing and reuse; not part of the public channel API. |
Return the list of control keys that will be stripped from the data bag.
at line 75
static private array
logData(object $notifiable, Notification $notification, array $payloadArr)
Build the consolidated "data" bag for logging.
Strategy: 1) Start with the notification’s {\Core\Lib\Notifications\Notification::toArray()} result. 2) Merge in the payload array minus control keys, allowing payload to override keys from step 1 so per‑send overrides are visible.
at line 111
static private string
logMessage(array $data, object $notifiable, string $notifiableClass, Notification $notification, string $notificationClass, string $payloadMessage)
Determine the human‑readable message to log.
Priority: 1) Non‑null payload‑provided message (already normalized to string) 2) Notification‑provided {\Core\Lib\Notifications\Notification::toLog()} string 3) "data['message']" if present and string 4) A synthesized "Notification X for Y" fallback
at line 138
static string
name()
Returns the canonical name of the channel.
Used by the notification dispatcher to identify this channel
when the notification's via() method includes "log".
at line 152
static private string
payloadMessage(array $payloadArr)
Extract a string message from the payload, if present.
Accepts either a string or any JSON‑serializable value under the "message" key. Non‑string values are JSON‑encoded with unicode and slashes preserved.
at line 180
void
send(object $notifiable, Notification $notification, mixed $payload)
Send the given notification to the log.
If the notification implements a toLog() method, its return
value will be used as the log message. Otherwise, if the
notification implements toArray(), the array will be logged.
If neither method exists, the notifiable itself is cast to string.
The output is encoded as JSON and written at INFO level.