<commit_before><?php

namespace Bolt\Logger\Handler;

use Bolt\Application;
use Bolt\Helpers\String;
use Bolt\Logger\Formatter\System;
use Monolog\Logger;
use Monolog\Handler\AbstractProcessingHandler;

/**
 * Monolog Database handler for system logging
 *
 * @author <NAME> <<EMAIL>>
 */
class SystemHandler extends AbstractProcessingHandler
{
    /**
     * @var Application
     */
    private $app;

    /**
     * @var boolean
     */
    private $initialized = false;

    /**
     * @var string
     */
    private $tablename;

    /**
     *
     * @param Application $app
     * @param string      $logger
     * @param integer     $level
     * @param boolean     $bubble
     */
    public function __construct(Application $app, $level = Logger::DEBUG, $bubble = true)
    {
        $this->app = $app;
        parent::__construct($level, $bubble);
    }

    /**
     * Handle
     *
     * @param  array   $record
     * @return boolean
     */
    public function handle(array $record)
    {
        if (!$this->isHandling($record)) {
            return false;
        }

        $record = $this->processRecord($record);
        $record['formatted'] = $this->getFormatter()->format($record);
        $this->write($record);

        return false === $this->bubble;
    }

    protected function write(array $record)
    {
        if (!$this->initialized) {
            $this->initialize();
        }

        if ($this->app['config']->get('general/debug')) {
            $backtrace = debug_backtrace();
            $filename = str_replace($this->app['resources']->getPath('root'), "", $backtrace[3]['file']);
            $record['message'] .= "\nFile: " . $filename;
            $record['message'] .= "\nLine: " . $backtrace[3]['line'];
        }

        $this->user = $this->app['session']->get('user');

        try {
            $this->app['db']->insert($this->tablename, array(
                'level'       => $record['level'],
                'date'        => $record['datetime']->format('Y-m-d H:i:s'),
                'message'     => $record['message'],
                'ownerid'     => isset($this->user['id']) ? $this->user['id'] : '',
                'requesturi'  => $this->app['request']->getRequestUri(),
                'route'       => $this->app['request']->get('_route'),
                'ip'          => $this->app['request']->getClientIp(),<commit_msg>We don't need no...  Class property!<commit_after><?php

namespace Bolt\Logger\Handler;

use Bolt\Application;
use Bolt\Helpers\String;
use Bolt\Logger\Formatter\System;
use Monolog\Logger;
use Monolog\Handler\AbstractProcessingHandler;

/**
 * Monolog Database handler for system logging
 *
 * @author <NAME> <<EMAIL>>
 */
class SystemHandler extends AbstractProcessingHandler
{
    /**
     * @var Application
     */
    private $app;

    /**
     * @var boolean
     */
    private $initialized = false;

    /**
     * @var string
     */
    private $tablename;

    /**
     *
     * @param Application $app
     * @param string      $logger
     * @param integer     $level
     * @param boolean     $bubble
     */
    public function __construct(Application $app, $level = Logger::DEBUG, $bubble = true)
    {
        $this->app = $app;
        parent::__construct($level, $bubble);
    }

    /**
     * Handle
     *
     * @param  array   $record
     * @return boolean
     */
    public function handle(array $record)
    {
        if (!$this->isHandling($record)) {
            return false;
        }

        $record = $this->processRecord($record);
        $record['formatted'] = $this->getFormatter()->format($record);
        $this->write($record);

        return false === $this->bubble;
    }

    protected function write(array $record)
    {
        if (!$this->initialized) {
            $this->initialize();
        }

        if ($this->app['config']->get('general/debug')) {
            $backtrace = debug_backtrace();
            $filename = str_replace($this->app['resources']->getPath('root'), "", $backtrace[3]['file']);
            $record['message'] .= "\nFile: " . $filename;
            $record['message'] .= "\nLine: " . $backtrace[3]['line'];
        }

        $user = $this->app['session']->get('user');

        try {
            $this->app['db']->insert($this->tablename, array(
                'level'       => $record['level'],
                'date'        => $record['datetime']->format('Y-m-d H:i:s'),
                'message'     => $record['message'],
                'ownerid'     => isset($user['id']) ? $user['id'] : '',
                'requesturi'  => $this->app['request']->getRequestUri(),
                'route'       => $this->app['request']->get('_route'),
                'ip'          => $this->app['request']->getClientIp(),
{'fraction_non_alphanumeric': 0.181075989114507, 'fraction_numerical': 0.0008373456144023446, 'mean_word_length': 2.053035143769968, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 76, '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': '3612860', 'n_tokens_mistral': 1413, 'n_tokens_neox': 1391, 'n_words': 256}