Skip to content

add dependency management for sender class #81

Description

@Grummfy

I try to create a MonologSender for dev, (syslog doesn't work as expected on docker ...)

<?php

use Liuggio\StatsdClient\Sender\SenderInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;

class MonologSender implements SenderInterface
{
    public LoggerInterface $logger;
    private string $priority = LogLevel::DEBUG;


    public function __construct(LoggerInterface $logger, $priority = LogLevel::DEBUG)
    {
        $this->logger = $logger;
        $this->priority = $priority;
    }

    public function open()
    {
        return true;
    }

    function write($handle, $message, $length = null)
    {
        $this->logger->log($this->priority, sprintf('statsd-client-write "%s" %d Bytes', $message, strlen($message)));

        return strlen($message);
    }

    function close($handle)
    {
    }
}

but impossible to find a way to make the dependency wired properly to it, it could be a nice stuff to find a way to properly init theses classes

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions