Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dependency management for sender class #81

Open
Grummfy opened this issue Aug 12, 2020 · 0 comments
Open

add dependency management for sender class #81

Grummfy opened this issue Aug 12, 2020 · 0 comments

Comments

@Grummfy
Copy link

Grummfy commented Aug 12, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant