<?php 

namespace App\Bundle\Utils;

class Logger
{
    public static function send($data, $fileName = 'logger.log')
    {
        $fileLog = dirname(__DIR__, 3) 
            . DIRECTORY_SEPARATOR .'var'
            . DIRECTORY_SEPARATOR. 'log'
            . DIRECTORY_SEPARATOR . $fileName;
        $current = '';

        if (file_exists($fileLog)) {
            $current = file_get_contents($fileLog);
            $current .= "\n";
        }

        $current .= json_encode([
            'datetime' => \date('Y-m-d H:i:s'),
            'data' => $data
        ], JSON_UNESCAPED_UNICODE);
        
        file_put_contents($fileLog, $current);

        // $conn = $event->getConnection();
        // $conn->executeQuery("SET NAMES UTF8");
    }
}
