<commit_before><?php

namespace PHPCD;

use Psr\Log\LoggerInterface;
use Psr\Log\AbstractLogger;

class Logger extends AbstractLogger
{
    private $log_file;

    public function __construct($log_path)
    {
        // @todo handle bugs with opening log file
        $this->log_file = fopen($log_path, 'a');
    }

    public function __destruct()
    {
        fclose($this->log_file);
    }

    /**
     * Logs with an arbitrary level.
     *
     * @param mixed  $level
     * @param string $message
     * @param array  $context
     *<commit_msg>Default log path for PHPCD\Logger<commit_after><?php

namespace PHPCD;

use Psr\Log\LoggerInterface;
use Psr\Log\AbstractLogger;

class Logger extends AbstractLogger
{
    private $log_file;

    private $log_path;

    public function __construct($log_path = null)
    {
        $this->setLogPath($log_path);

        // @todo handle bugs with opening log file
        $this->log_file = fopen($this->log_path, 'a');
    }

    private function setLogPath($log_path = null)
    {
        if (!$log_path) {
            $log_path = getenv('HOME') . '/.phpcd.log';
        }

        $this->log_path = $log_path;

        return $this;
    }

    public function __destruct()
    {
        fclose($this->log_file);
    }

    /**
     * Logs with an arbitrary level.
     *
     * @param mixed  $level
     * @param string $message
     * @param array  $context
     *
{'fraction_non_alphanumeric': 0.11706629055007052, 'fraction_numerical': 0.0, 'mean_word_length': 2.269585253456221, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, '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': '5124660', 'n_tokens_mistral': 461, 'n_tokens_neox': 447, 'n_words': 109}