<commit_before><?php

namespace ETNA\Silex\Provider\StudentLogs;

use ETNA\Monolog\Handler\StudentLogsHandler;

use Silex\Application;
use Silex\ServiceProviderInterface;

use Monolog\Formatter\LineFormatter;
use Monolog\Logger;
use Monolog\Handler\SyslogUdpHandler;

class StudentLogsProvider implements ServiceProviderInterface
{
    /**
     * {@inheritDoc}
     */
    public function boot(Application $app)
    {
        return $app;
    }

    /**
     * {@inheritDoc}
     */
    public function register(Application $app)
    {
        $app['amqp.queues.options'] = array_merge($app['amqp.queues.options'], [
            'students_logs' => [
                'passive'     => false,
                'durable'     => true,
                'exclusive'   => false,
                'auto_delete' => false,
                'exchange'    => 'default',
                'routing.key' => 'students_logs',
                'channel'     => 'default',
            ],
        ]);

        $log = new Logger('students_logs');
        $log->pushHandler(new StudentLogsHandler($app['amqp.queues']['students_logs']));

        $syslog = new SyslogUdpHandler("172.16.128.219");
        $syslog->setFormatter(new LineFormatter('%context%'));
        $log->pushHandler($syslog);

        $app['students_logs'] = $log;
    }
}<commit_msg>[FEATURE#17739] Syslog ip et environnement<commit_after><?php

namespace ETNA\Silex\Provider\StudentLogs;

use ETNA\Monolog\Handler\StudentLogsHandler;

use Silex\Application;
use Silex\ServiceProviderInterface;

use Monolog\Formatter\LineFormatter;
use Monolog\Logger;
use Monolog\Handler\SyslogUdpHandler;

class StudentLogsProvider implements ServiceProviderInterface
{
    /**
     * {@inheritDoc}
     */
    public function boot(Application $app)
    {
        return $app;
    }

    /**
     * {@inheritDoc}
     */
    public function register(Application $app)
    {
        $app['amqp.queues.options'] = array_merge($app['amqp.queues.options'], [
            'students_logs' => [
                'passive'     => false,
                'durable'     => true,
                'exclusive'   => false,
                'auto_delete' => false,
                'exchange'    => 'default',
                'routing.key' => 'students_logs',
                'channel'     => 'default',
            ],
        ]);

        $log = new Logger('students_logs');
        $log->pushHandler(new StudentLogsHandler($app['amqp.queues']['students_logs']));

        $syslog_ip = getenv("STUDENT_SYSLOG_IP");
        if (false === $syslog_ip) {
            throw new \Exception("The environment variable STUDENT_SYSLOG_IP is not set");
        }

        $syslog = new SyslogUdpHandler($syslog_ip);
        $syslog->setFormatter(new LineFormatter('%context%'));
        $log->pushHandler($syslog);

        $app['students_logs'] = $log;
    }
}
{'fraction_non_alphanumeric': 0.1392095138160196, 'fraction_numerical': 0.005596362364463099, 'mean_word_length': 2.310185185185185, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6172325', 'n_tokens_mistral': 891, 'n_tokens_neox': 856, 'n_words': 140}