📂 File Browser

/AgentAI/vendor/monolog/monolog/src/Monolog/Formatter
🌙 Dark Mode
🎯 Quick Launch:

📁 Directories

📄 Files

🐘 ChromePHPFormatter.php
▶ Open 📄 View Source
🐘 ElasticaFormatter.php
▶ Open 📄 View Source
🐘 ElasticsearchFormatter.php
▶ Open 📄 View Source
🐘 FlowdockFormatter.php
▶ Open 📄 View Source
🐘 FluentdFormatter.php
▶ Open 📄 View Source
🐘 FormatterInterface.php
▶ Open 📄 View Source
🐘 GelfMessageFormatter.php
▶ Open 📄 View Source
🐘 GoogleCloudLoggingFormatter.php
▶ Open 📄 View Source
🐘 HtmlFormatter.php
▶ Open 📄 View Source
🐘 JsonFormatter.php
▶ Open 📄 View Source
🐘 LineFormatter.php
▶ Open 📄 View Source
🐘 LogglyFormatter.php
▶ Open 📄 View Source
🐘 LogmaticFormatter.php
▶ Open 📄 View Source
🐘 LogstashFormatter.php
▶ Open 📄 View Source
🐘 MongoDBFormatter.php
▶ Open 📄 View Source
🐘 NormalizerFormatter.php
▶ Open 📄 View Source
🐘 ScalarFormatter.php
▶ Open 📄 View Source
🐘 SyslogFormatter.php
▶ Open 📄 View Source
🐘 WildfireFormatter.php
▶ Open 📄 View Source

📄 Source: LogglyFormatter.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\Formatter;

use Monolog\LogRecord;

/**
 * Encodes message information into JSON in a format compatible with Loggly.
 *
 * @author Adam Pancutt <adam@pancutt.com>
 */
class LogglyFormatter extends JsonFormatter
{
    /**
     * Overrides the default batch mode to new lines for compatibility with the
     * Loggly bulk API.
     */
    public function __construct(int $batchMode = self::BATCH_MODE_NEWLINES, bool $appendNewline = false)
    {
        parent::__construct($batchMode, $appendNewline);
    }

    /**
     * Appends the 'timestamp' parameter for indexing by Loggly.
     *
     * @see https://www.loggly.com/docs/automated-parsing/#json
     * @see \Monolog\Formatter\JsonFormatter::format()
     */
    protected function normalizeRecord(LogRecord $record): array
    {
        $recordData = parent::normalizeRecord($record);

        $recordData["timestamp"] = $record->datetime->format("Y-m-d\TH:i:s.uO");
        unset($recordData["datetime"]);

        return $recordData;
    }
}
← Back