<commit_before><?php

namespace Chamilo\Libraries\Architecture\ErrorHandler\ExceptionLogger;

/**
 * Logs errors to a file
 *
 * @author <NAME> - Hogesch<NAME>
 */
class FileExceptionLogger implements ExceptionLoggerInterface
{
    /**
     * The path to the log directory
     *
     * @var string
     */
    protected $logPath;

    /**
     * FileLoggerErrorHandler constructor.
     *
     * @param $logPath
     *
     * @throws \Exception
     */
    public function __construct($logPath)
    {
        if (empty($logPath))
        {
            throw new \Exception('The given log path can not be empty');
        }

        if (!file_exists($logPath) || !is_dir($logPath) || !is_writable($logPath))
        {
            throw new \Exception(
                sprintf('The given log path either does not exist or is not a valid directory. (%s)', $logPath)
            );
        }

        $this->logPath = $logPath;
    }

    /**
     * Logs an exception
     *
     * @param \Exception $exception
     * @param int $exceptionLevel
     * @param string $file
     * @param int $line
     */
    public function logException($exception, $exceptionLevel = self::EXCEPTION_LEVEL_ERROR, $file = null, $line = 0)
    {
        if($exceptionLevel != self::EXCEPTION_LEVEL_WARNING)
        {
            return;
        }

        $logFile = $this->logPath . DIRECTORY_SEPARATOR . 'FatalErrors.log';
        $fileHandler = fopen($logFile, 'a');

        $type = $this->determineExceptionLevelString($exceptionLevel);

        $message = date('[d/m/Y - H:i:s] ', time()) . ' - [' . $type . '] ' . $exception->getMessage();

        if (!is_null($file))
        {
            $message .= ' - FILE: ' . $file . ' - LINE: ' . $line;
        }

        fwrite($fileHandler, $message . "\n");
        fclose($fileHandler);
    }
<commit_msg>[Libraries] Removed warning from file exception logger<commit_after><?php

namespace Chamilo\Libraries\Architecture\ErrorHandler\ExceptionLogger;

/**
 * Logs errors to a file
 *
 * @author <NAME> - Hogeschool Gent
 */
class FileExceptionLogger implements ExceptionLoggerInterface
{
    /**
     * The path to the log directory
     *
     * @var string
     */
    protected $logPath;

    /**
     * FileLoggerErrorHandler constructor.
     *
     * @param $logPath
     *
     * @throws \Exception
     */
    public function __construct($logPath)
    {
        if (empty($logPath))
        {
            throw new \Exception('The given log path can not be empty');
        }

        if (!file_exists($logPath) || !is_dir($logPath) || !is_writable($logPath))
        {
            throw new \Exception(
                sprintf('The given log path either does not exist or is not a valid directory. (%s)', $logPath)
            );
        }

        $this->logPath = $logPath;
    }

    /**
     * Logs an exception
     *
     * @param \Exception $exception
     * @param int $exceptionLevel
     * @param string $file
     * @param int $line
     */
    public function logException($exception, $exceptionLevel = self::EXCEPTION_LEVEL_ERROR, $file = null, $line = 0)
    {
        if($exceptionLevel == self::EXCEPTION_LEVEL_WARNING)
        {
            return;
        }

        $logFile = $this->logPath . DIRECTORY_SEPARATOR . 'FatalErrors.log';
        $fileHandler = fopen($logFile, 'a');

        $type = $this->determineExceptionLevelString($exceptionLevel);

        $message = date('[d/m/Y - H:i:s] ', time()) . ' - [' . $type . '] ' . $exception->getMessage();

        if (!is_null($file))
        {
            $message .= ' - FILE: ' . $file . ' - LINE: ' . $line;
        }

        fwrite($fileHandler, $message . "\n");
        fclose($fileHandler);
    }

{'fraction_non_alphanumeric': 0.1382091960204356, 'fraction_numerical': 0.0005377789728421619, 'mean_word_length': 2.034257748776509, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '1895299', 'n_tokens_mistral': 1122, 'n_tokens_neox': 1090, 'n_words': 255}