๐Ÿ“‚ File Browser

//AgentAI/vendor/monolog/monolog/src/Monolog/Handler
๐ŸŒ™ Dark Mode
๐ŸŽฏ Quick Launch:

๐Ÿ“ Directories

๐Ÿ“ Curl/ ๐Ÿ”“ Open
๐Ÿ“ FingersCrossed/ ๐Ÿ”“ Open
๐Ÿ“ Slack/ ๐Ÿ”“ Open
๐Ÿ“ SyslogUdp/ ๐Ÿ”“ Open

๐Ÿ“„ Files

๐Ÿ˜ AbstractHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ AbstractProcessingHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ AbstractSyslogHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ AmqpHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ BrowserConsoleHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ BufferHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ ChromePHPHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ CouchDBHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ CubeHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ DeduplicationHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ DoctrineCouchDBHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ DynamoDbHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ ElasticaHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ ElasticsearchHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ ErrorLogHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ FallbackGroupHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ FilterHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ FingersCrossedHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ FirePHPHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ FleepHookHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ FlowdockHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ FormattableHandlerInterface.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ FormattableHandlerTrait.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ GelfHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ GroupHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ Handler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ HandlerInterface.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ HandlerWrapper.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ IFTTTHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ InsightOpsHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ LogEntriesHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ LogglyHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ LogmaticHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ MailHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ MandrillHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ MissingExtensionException.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ MongoDBHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ NativeMailerHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ NewRelicHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ NoopHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ NullHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ OverflowHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ PHPConsoleHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ ProcessHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ ProcessableHandlerInterface.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ ProcessableHandlerTrait.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ PsrHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ PushoverHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ RedisHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ RedisPubSubHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ RollbarHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ RotatingFileHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ SamplingHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ SendGridHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ SlackHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ SlackWebhookHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ SocketHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ SqsHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ StreamHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ SymfonyMailerHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ SyslogHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ SyslogUdpHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ TelegramBotHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ TestHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ WebRequestRecognizerTrait.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ WhatFailureGroupHandler.php
โ–ถ Open ๐Ÿ“„ View Source
๐Ÿ˜ ZendMonitorHandler.php
โ–ถ Open ๐Ÿ“„ View Source

๐Ÿ“„ Source: ErrorLogHandler.php

<?php declare(strict_types=1);

/*
 * This file is part of the Monolog package.
 *
 * (c) Jordi Boggiano <j.boggiano@seld.be>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Monolog\Handler;

use Monolog\Formatter\LineFormatter;
use Monolog\Formatter\FormatterInterface;
use Monolog\Level;
use Monolog\Utils;
use Monolog\LogRecord;

/**
 * Stores to PHP error_log() handler.
 *
 * @author Elan Ruusamรคe <glen@delfi.ee>
 */
class ErrorLogHandler extends AbstractProcessingHandler
{
    public const OPERATING_SYSTEM = 0;
    public const SAPI = 4;

    /** @var 0|4 */
    protected int $messageType;
    protected bool $expandNewlines;

    /**
     * @param 0|4 $messageType    Says where the error should go.
     * @param bool $expandNewlines If set to true, newlines in the message will be expanded to be take multiple log entries
     *
     * @throws \InvalidArgumentException If an unsupported message type is set
     */
    public function __construct(int $messageType = self::OPERATING_SYSTEM, int|string|Level $level = Level::Debug, bool $bubble = true, bool $expandNewlines = false)
    {
        parent::__construct($level, $bubble);

        if (false === \in_array($messageType, self::getAvailableTypes(), true)) {
            $message = sprintf('The given message type "%s" is not supported', print_r($messageType, true));

            throw new \InvalidArgumentException($message);
        }

        $this->messageType = $messageType;
        $this->expandNewlines = $expandNewlines;
    }

    /**
     * @return int[] With all available types
     */
    public static function getAvailableTypes(): array
    {
        return [
            self::OPERATING_SYSTEM,
            self::SAPI,
        ];
    }

    /**
     * @inheritDoc
     */
    protected function getDefaultFormatter(): FormatterInterface
    {
        return new LineFormatter('[%datetime%] %channel%.%level_name%: %message% %context% %extra%');
    }

    /**
     * @inheritDoc
     */
    protected function write(LogRecord $record): void
    {
        if (!$this->expandNewlines) {
            error_log((string) $record->formatted, $this->messageType);

            return;
        }

        $lines = preg_split('{[\r\n]+}', (string) $record->formatted);
        if ($lines === false) {
            $pcreErrorCode = preg_last_error();

            throw new \RuntimeException('Failed to preg_split formatted string: ' . $pcreErrorCode . ' / '. preg_last_error_msg());
        }
        foreach ($lines as $line) {
            error_log($line, $this->messageType);
        }
    }
}
โ† Back