Neuron-PHP

Sqs extends DestinationBase
in package

Outputs log data to Amazon SQS (Simple Queue Service).

This destination sends log messages to an AWS SQS queue for centralized processing, analysis, or forwarding to other systems. Supports batching for improved performance and custom message attributes.

Table of Contents

Properties

$_filters  : array<string|int, mixed>
$_format  : IFormat
$_parent  : ILogger|null
$_stdErr  : mixed
$_stdOut  : mixed
$autoFlush  : bool
$batchBuffer  : array<string|int, mixed>
$batchSize  : int
$client  : SqsClient|null
$maxRetries  : int
$messageAttributes  : array<string|int, mixed>
$queueUrl  : string
$retryDelay  : float

Methods

__construct()  : mixed
__destruct()  : mixed
Ensure batch is flushed on destruction.
addFilter()  : bool
Adds a logging filter.
close()  : void
Close the SQS connection and flush any remaining messages.
flushBatch()  : void
Flush the batch buffer to SQS.
getParent()  : ILogger
Gets the parent logger.
getStdErr()  : mixed
getStdOut()  : mixed
log()  : void
Handles writing the log data after filtering and formatting.
open()  : bool
Configure the SQS connection.
removeFilter()  : bool
Removes a logging filter.
setFileHandles()  : void
Maps STDERR and STDOUT to file handles in non-CLI environments.
setFormat()  : void
Sets the formatter.
setParent()  : void
Sets the parent logger.
write()  : void
Write log data to SQS queue.
buildMessage()  : array<string|int, mixed>
Build SQS message from log data.
sendSingleMessage()  : void
Send a single message to SQS.

Properties

$autoFlush

private bool $autoFlush = true

$batchBuffer

private array<string|int, mixed> $batchBuffer = []

$batchSize

private int $batchSize = 1

$client

private SqsClient|null $client = null

$maxRetries

private int $maxRetries = 3

$messageAttributes

private array<string|int, mixed> $messageAttributes = []

$queueUrl

private string $queueUrl

$retryDelay

private float $retryDelay = 1.0

Methods

__destruct()

Ensure batch is flushed on destruction.

public __destruct() : mixed

close()

Close the SQS connection and flush any remaining messages.

public close() : void

flushBatch()

Flush the batch buffer to SQS.

public flushBatch() : void

log()

Handles writing the log data after filtering and formatting.

public log(mixed $text, mixed $level[, mixed $context = [] ]) : void
Parameters
$text : mixed
  • Output that has been run through the formatter.
$level : mixed
  • Text output level.
$context : mixed = []
  • Optional context array

open()

Configure the SQS connection.

public open(array<string|int, mixed> $params) : bool

Parameters:

  • queue_url: Full SQS queue URL (required)
  • region: AWS region (required)
  • credentials: Array with 'key' and 'secret', or omit for IAM role (optional)
  • batch_size: Number of messages to batch (1-10, default 1)
  • auto_flush: Automatically flush on destruct (default true)
  • attributes: Default message attributes to include (optional)
  • max_retries: Maximum retry attempts on failure (default 3)
  • retry_delay: Initial delay between retries in seconds (default 1.0)
Parameters
$params : array<string|int, mixed>

Configuration parameters

Tags
throws
Exception
Return values
bool

removeFilter()

Removes a logging filter.

public removeFilter(IFilter $removeFilter) : bool
Parameters
$removeFilter : IFilter
Return values
bool

setFileHandles()

Maps STDERR and STDOUT to file handles in non-CLI environments.

public setFileHandles() : void

write()

Write log data to SQS queue.

public write(string $text, Data $data) : void
Parameters
$text : string

Formatted log message

$data : Data

Log data object

buildMessage()

Build SQS message from log data.

private buildMessage(string $text, Data $data) : array<string|int, mixed>
Parameters
$text : string
$data : Data
Return values
array<string|int, mixed>

sendSingleMessage()

Send a single message to SQS.

private sendSingleMessage(array<string|int, mixed> $message) : void
Parameters
$message : array<string|int, mixed>

        
On this page

Search results