<commit_before><?php

namespace Contributte\Logging;

use DirectoryIterator;
use Exception;

/**
 * AbstractTracyLogger based on official Tracy\Logger (@copyright David Grudl)
 *
 * @author <NAME> <<EMAIL>>
 */
abstract class AbstractLogger implements ILogger
{

	/** @var string */
	protected $directory;

	/**
	 * @param string $directory
	 */
	public function __construct($directory)
	{
		$this->directory = $directory;
	}

	/**
	 * @param string $directory
	 * @return void
	 */
	public function setDirectory($directory)
	{
		$this->directory = $directory;
	}

	/**
	 * @param Exception $exception
	 * @return string
	 */
	protected function getExceptionFile($exception)
	{
		while ($exception) {
			$data[] = [
				$exception->getMessage(),
				$exception->getCode(),
				$exception->getFile(),
				$exception->getLine(),
				array_map(function ($item) {
					unset($item['args']);

					return $item;
				}, $exception->getTrace()),
			];
			$exception = $exception->getPrevious();
		}
		$hash = substr(md5(serialize($data)), 0, 10);
		foreach (new DirectoryIterator($this->directory) as $file) {
			if (strpos($file, $hash)) {
				return $this->directory . $file;
			}
		}
<commit_msg>Fix logging into parent directory<commit_after><?php

namespace Contributte\Logging;

use DirectoryIterator;
use Exception;

/**
 * AbstractTracyLogger based on official Tracy\Logger (@copyright David Grudl)
 *
 * @author <NAME> <<EMAIL>>
 */
abstract class AbstractLogger implements ILogger
{

	/** @var string */
	protected $directory;

	/**
	 * @param string $directory
	 */
	public function __construct($directory)
	{
		$this->directory = $directory;
	}

	/**
	 * @param string $directory
	 * @return void
	 */
	public function setDirectory($directory)
	{
		$this->directory = $directory;
	}

	/**
	 * @param Exception $exception
	 * @return string
	 */
	protected function getExceptionFile($exception)
	{
		while ($exception) {
			$data[] = [
				$exception->getMessage(),
				$exception->getCode(),
				$exception->getFile(),
				$exception->getLine(),
				array_map(function ($item) {
					unset($item['args']);

					return $item;
				}, $exception->getTrace()),
			];
			$exception = $exception->getPrevious();
		}
		$hash = substr(md5(serialize($data)), 0, 10);
		
		/** @var \SplFileInfo $file */
		foreach (new DirectoryIterator($this->directory) as $file) {
			if ($file->isDot()) {
				continue;
			}
			if (strpos($file, $hash)) {
				return $file->getPathname();
			}
		}

{'fraction_non_alphanumeric': 0.16532258064516128, 'fraction_numerical': 0.0032258064516129032, 'mean_word_length': 3.602968460111317, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 30, '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': '7449998', 'n_tokens_mistral': 893, 'n_tokens_neox': 760, 'n_words': 175}