CodeExplorer createSocket example
$this->contextProviders =
$contextProviders;
} public function getContextProviders(): array
{ return $this->contextProviders;
} public function write(Data
$data): bool
{ $socketIsFresh = !
$this->socket;
if (!
$this->socket =
$this->socket ?:
$this->
createSocket()) { return false;
} $context =
['timestamp' =>
microtime(true
)];
foreach ($this->contextProviders
as $name =>
$provider) { $context[$name] =
$provider->
getContext();
} $context =
array_filter($context);
$encodedPayload =
base64_encode(serialize([$data,
$context]))."\n";
set_error_handler(fn () => true
);
private function doHandle(array|LogRecord
$record): bool
{ if (!
$this->
isHandling($record)) { return false;
} set_error_handler(static fn () => null
);
try { if (!
$this->socket =
$this->socket ?:
$this->
createSocket()) { return false ===
$this->bubble;
} } finally { restore_error_handler();
} return parent::
handle($record);
} private function doWrite(array|LogRecord
$record): void
{ $this->contextProviders =
$contextProviders;
} public function getContextProviders(): array
{ return $this->contextProviders;
} public function write(Data
$data): bool
{ $socketIsFresh = !
$this->socket;
if (!
$this->socket =
$this->socket ?:
$this->
createSocket()) { return false;
} $context =
['timestamp' =>
microtime(true
)];
foreach ($this->contextProviders
as $name =>
$provider) { $context[$name] =
$provider->
getContext();
} $context =
array_filter($context);
$encodedPayload =
base64_encode(serialize([$data,
$context]))."\n";
set_error_handler(static fn () => null
);