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
$_filters
private
array<string|int, mixed>
$_filters
= []
$_format
private
IFormat
$_format
$_parent
private
ILogger|null
$_parent
= null
$_stdErr
private
mixed
$_stdErr
$_stdOut
private
mixed
$_stdOut
$facility
private
int
$facility
= 16
$host
private
string
$host
$isConnected
private
bool
$isConnected
= false
$maxReconnectAttempts
private
int
$maxReconnectAttempts
= 5
$port
private
int
$port
$reconnectAttempts
private
int
$reconnectAttempts
= 0
$sdId
private
string
$sdId
= 'neuron@32473'
$socket
private
mixed
$socket
= null
$systemName
private
string
$systemName
$useTls
private
bool
$useTls
Methods
__construct()
public
__construct(IFormat $format) : mixed
Parameters
- $format : IFormat
__destruct()
Clean up on destruction.
public
__destruct() : mixed
addFilter()
Adds a logging filter.
public
addFilter(IFilter $filter) : bool
Parameters
- $filter : IFilter
Return values
boolclose()
Close the connection.
public
close() : void
getParent()
Gets the parent logger.
public
getParent() : ILogger
Return values
ILoggergetStdErr()
public
getStdErr() : mixed
getStdOut()
public
getStdOut() : mixed
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
boolremoveFilter()
Removes a logging filter.
public
removeFilter(IFilter $removeFilter) : bool
Parameters
- $removeFilter : IFilter
Return values
boolsetFileHandles()
Maps STDERR and STDOUT to file handles in non-CLI environments.
public
setFileHandles() : void
setFormat()
Sets the formatter.
public
setFormat(IFormat $format) : void
Parameters
- $format : IFormat
setParent()
Sets the parent logger.
public
setParent(ILogger $logger) : void
Parameters
- $logger : ILogger
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
stringconnect()
Connect to Papertrail server.
private
connect() : bool
Return values
boolformatSyslogMessage()
Format message according to syslog RFC 5424.
private
formatSyslogMessage(string $text, Data $data) : string
Parameters
- $text : string
- $data : Data
Return values
stringgetSeverity()
Convert log level to syslog severity.
private
getSeverity(RunLevel $level) : int
Parameters
- $level : RunLevel
Return values
intreconnect()
Attempt to reconnect to Papertrail.
private
reconnect() : bool