<commit_before><?php

use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase;
use SuiteCRM\Utility\Paths;
use SuiteCRM\Utility\SuiteLogger;

class SuiteLoggerTest extends SuitePHPUnitFrameworkTestCase
{
    /**
     * @var SuiteLogger
     */
    private static $logger;

    /**
     * @var string
     */
    private static $oldLogLevel;

    public function setUp()
    {
        parent::setUp();
        if (self::$logger === null) {
            self::$logger = new SuiteLogger();
        }

        $loggerManager = LoggerManager::getLogger();

        if (self::$logger === null) {
            self::$oldLogLevel = $loggerManager::getLogLevel();
        }

        $loggerManager::setLogLevel('debug');
    }

    public function tearDown()
    {
        $loggerManager = LoggerManager::getLogger();
        $loggerManager::setLogLevel(self::$oldLogLevel);
        self::$logger = null;
        parent::tearDown();
    }

    public function testLogEmergency()
    {
        self::$logger->emergency('test');
        $lastLine = $this->getLastLogMessage();
        preg_match('/\[EMERGENCY\] test/', $lastLine, $matches);
        $this->assertNotEmpty($matches);
    }

    public function testLogAlert()
    {
        self::$logger->alert('test');
        $lastLine = $this->getLastLogMessage();<commit_msg>Fixed SuiteLoggerTest never retrieving the log level<commit_after><?php

use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase;
use SuiteCRM\Utility\Paths;
use SuiteCRM\Utility\SuiteLogger;

class SuiteLoggerTest extends SuitePHPUnitFrameworkTestCase
{
    /**
     * @var SuiteLogger
     */
    private static $logger;

    /**
     * @var string
     */
    private static $oldLogLevel;

    public function setUp()
    {
        parent::setUp();
        if (self::$logger === null) {
            self::$logger = new SuiteLogger();
        }

        $loggerManager = LoggerManager::getLogger();
        self::$oldLogLevel = $loggerManager::getLogLevel();

        $loggerManager::setLogLevel('debug');
    }

    public function tearDown()
    {
        $loggerManager = LoggerManager::getLogger();
        $loggerManager::setLogLevel(self::$oldLogLevel);
        self::$logger = null;
        parent::tearDown();
    }

    public function testLogEmergency()
    {
        self::$logger->emergency('test');
        $lastLine = $this->getLastLogMessage();
        preg_match('/\[EMERGENCY\] test/', $lastLine, $matches);
        $this->assertNotEmpty($matches);
    }

    public function testLogAlert()
    {
        self::$logger->alert('test');
        $lastLine = $this->getLastLogMessage();
{'fraction_non_alphanumeric': 0.14153846153846153, 'fraction_numerical': 0.0, 'mean_word_length': 2.7157142857142857, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '3520393', 'n_tokens_mistral': 743, 'n_tokens_neox': 745, 'n_words': 132}