<commit_before><?php

error_reporting(E_ALL);
date_default_timezone_set('Europe/Berlin');

require_once __DIR__.'/../vendor/autoload.php';

use JourneyMonitor\Monitor\Base\TestcaseRepository;
use JourneyMonitor\Monitor\Base\TestresultRepository;
use JourneyMonitor\Monitor\Base\EnvironmentInfo;
use JourneyMonitor\Monitor\Base\Logger;
use JourneyMonitor\Monitor\JobRunner\Runner;
use JourneyMonitor\Monitor\JobRunner\Notifier;

if (!array_key_exists(1, $argv)) {
    exit(1);
}
$testcaseId = $argv[1];

$environmentInfo = new EnvironmentInfo();
$environmentName = $environmentInfo->getName();

$dbConnection = new PDO('sqlite:/var/tmp/journeymonitor-monitor-' . $environmentName . '.sqlite3');

$testcaseRepository = new TestcaseRepository($dbConnection);

$runner = new Runner($testcaseRepository, '/var/tmp', $testcaseId);
$runner->prepare();

print('About to start Selenium run...' . "\n");
$testresultModel = $runner->run();
print('Finished Selenium run.' . "\n");

print('About to persist testresult ' . $testresultModel->getId() . '...' . "\n");
$testresultRepository = new TestresultRepository($dbConnection, $testcaseRepository);
$testresultRepository->add($testresultModel);
print('Finished persisting testresult ' . $testresultModel->getId() . '.' . "\n");

print('About to handle notifications...' . "\n");
$sendMail = function($receiver, $subject, $body) {
    print('Sending mail to ' . $receiver . '...' . "\n");
    mail($receiver, $subject, $body);
    print('Finished sending mail to ' . $receiver . '.' . "\n");
};

$notifier = new Notifier($testresultRepository, $sendMail, new Logger());
$notifier->handle($testresultModel);
print('Finished handling notifications.' . "\n");
<commit_msg>Switched from print to logger.<commit_after><?php

error_reporting(E_ALL);
date_default_timezone_set('Europe/Berlin');

require_once __DIR__.'/../vendor/autoload.php';

use JourneyMonitor\Monitor\Base\TestcaseRepository;
use JourneyMonitor\Monitor\Base\TestresultRepository;
use JourneyMonitor\Monitor\Base\EnvironmentInfo;
use JourneyMonitor\Monitor\Base\Logger;
use JourneyMonitor\Monitor\JobRunner\Runner;
use JourneyMonitor\Monitor\JobRunner\Notifier;

if (!array_key_exists(1, $argv)) {
    exit(1);
}
$testcaseId = $argv[1];

$environmentInfo = new EnvironmentInfo();
$environmentName = $environmentInfo->getName();

$logger = new Logger();

$dbConnection = new PDO('sqlite:/var/tmp/journeymonitor-monitor-' . $environmentName . '.sqlite3');

$testcaseRepository = new TestcaseRepository($dbConnection);

$runner = new Runner($testcaseRepository, '/var/tmp', $testcaseId);
$runner->prepare();

$logger->info('About to start Selenium run...' . "\n");
$testresultModel = $runner->run();
$logger->info('Finished Selenium run, exit code was ' . $testresultModel->getExitCode() . "\n");

$logger->info('About to persist testresult ' . $testresultModel->getId() . '...' . "\n");
$testresultRepository = new TestresultRepository($dbConnection, $testcaseRepository);
$testresultRepository->add($testresultModel);
$logger->info('Finished persisting testresult ' . $testresultModel->getId() . '.' . "\n");

$logger->info('About to handle notifications...' . "\n");
$sendMail = function($receiver, $subject, $body) use ($logger) {
    $logger->info('Sending mail to ' . $receiver . '...' . "\n");
    mail($receiver, $subject, $body);
    $logger->info('Finished sending mail to ' . $receiver . '.' . "\n");
};

$notifier = new Notifier($testresultRepository, $sendMail, new Logger());
$notifier->handle($testresultModel);
$logger->info('Finished handling notifications.' . "\n");

{'fraction_non_alphanumeric': 0.17834217136477812, 'fraction_numerical': 0.0022327658386826683, 'mean_word_length': 5.661710037174721, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 26, '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': '3246704', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1089, 'n_words': 221}