Neuron-PHP

Papertrail extends DestinationBase
in package

Outputs log data to Papertrail via remote syslog protocol.

Supports both plain TCP and TLS-encrypted connections.

Table of Contents

Properties

$_filters  : array<string|int, mixed>
$_format  : IFormat
$_parent  : ILogger|null
$_stdErr  : mixed
$_stdOut  : mixed
$facility  : int
$host  : string
$isConnected  : bool
$maxReconnectAttempts  : int
$port  : int
$reconnectAttempts  : int
$sdId  : string
$socket  : mixed
$systemName  : string
$useTls  : bool

Methods

__construct()  : mixed
__destruct()  : mixed
Clean up on destruction.
addFilter()  : bool
Adds a logging filter.
close()  : void
Close the connection.
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 Papertrail 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 Papertrail.
buildStructuredData()  : string
Build structured data section for syslog message.
connect()  : bool
Connect to Papertrail server.
formatSyslogMessage()  : string
Format message according to syslog RFC 5424.
getSeverity()  : int
Convert log level to syslog severity.
reconnect()  : bool
Attempt to reconnect to Papertrail.

Properties

$maxReconnectAttempts

private int $maxReconnectAttempts = 5

$reconnectAttempts

private int $reconnectAttempts = 0

Methods

__destruct()

Clean up on destruction.

public __destruct() : mixed

close()

Close the connection.

public close() : 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 Papertrail connection.

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

Parameters: host - Papertrail host (e.g., "logs5.papertrailapp.com") port - Papertrail port system_name - System/app name for identification (optional) use_tls - Use TLS encryption (default: true) facility - Syslog facility (default: 16 for local0) sd_id - Structured data ID (default: 'neuron@32473')

Parameters
$params : array<string|int, mixed>
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 Papertrail.

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

buildStructuredData()

Build structured data section for syslog message.

private buildStructuredData(array<string|int, mixed> $context) : string
Parameters
$context : array<string|int, mixed>
Return values
string

connect()

Connect to Papertrail server.

private connect() : bool
Return values
bool

formatSyslogMessage()

Format message according to syslog RFC 5424.

private formatSyslogMessage(string $text, Data $data) : string
Parameters
$text : string
$data : Data
Return values
string

getSeverity()

Convert log level to syslog severity.

private getSeverity(RunLevel $level) : int
Parameters
$level : RunLevel
Return values
int

reconnect()

Attempt to reconnect to Papertrail.

private reconnect() : bool
Return values
bool

        
On this page

Search results