This commit is contained in:
team3
2026-06-03 22:05:20 +02:00
parent d7e8df6876
commit 40de56c27b
5119 changed files with 552560 additions and 24 deletions

View File

@@ -0,0 +1,120 @@
## Unreleased
## 3.10.0 (2023-11-06)
* Add configuration support for SamplingHandler
## 3.9.0 (2023-11-06)
* Add support for the `WithMonologChannel` attribute of Monolog 3.5.0 to autoconfigure the `monolog.logger` tag
* Add support for Symfony 7
* Remove support for Symfony 4
* Mark classes as internal when relevant
* Add support for env placeholders in the `level` option of handlers
## 3.8.0 (2022-05-10)
* Deprecated ambiguous `elasticsearch` type, use `elastica` instead
* Added support for Monolog 3.0 (requires symfony/monolog-bridge 6.1)
* Added support for `AsMonologProcessor` to autoconfigure processors
* Added support for `FallbackGroupHandler`
* Added support for `ElasticsearchHandler` as `elastic_search` type
* Added support for `ElasticaHandler` as `elastica` type
* Added support for `TelegramBotHandler` as `telegram`
* Added `fill_extra_context` flag for `sentry` handlers
* Added support for configuring PsrLogMessageProcessor (`date_format` and `remove_used_context_fields`)
* Fixed issue on Windows + PHP 8, workaround for https://github.com/php/php-src/issues/8315
* Fixed MongoDBHandler support when no client id is provided
## 3.7.1 (2021-11-05)
* Indicate compatibility with Symfony 6
## 3.7.0 (2021-03-31)
* Use `ActivationStrategy` instead of `actionLevel` when available
* Register resettable processors (`ResettableInterface`) for autoconfiguration (tag: `kernel.reset`)
* Drop support for Symfony 3.4
* Drop support for PHP < 7.1
* Fix call to undefined method pushProcessor on handler that does not implement ProcessableHandlerInterface
* Use "use_locking" option with rotating file handler
* Add ability to specify custom Sentry hub service
## 3.6.0 (2020-10-06)
* Added support for Symfony Mailer
* Added support for setting log levels from parameters or environment variables
## 3.5.0 (2019-11-13)
* Added support for Monolog 2.0
* Added `sentry` type to use sentry 2.0 client
* Added `insightops` handler
* Added possibility for auto-wire monolog channel according to the type-hinted aliases, introduced in the Symfony 4.2
## 3.4.0 (2019-06-20)
* Deprecate "excluded_404s" option
* Flush loggers on `kernel.reset`
* Register processors (`ProcessorInterface`) for autoconfiguration (tag: `monolog.processor`)
* Expose configuration for the `ConsoleHandler`
* Fixed psr-3 processing being applied to all handlers, only leaf ones are now processing
* Fixed regression when `app` channel is defined explicitly
* Fixed handlers marked as nested not being ignored properly from the stack
* Added support for Redis configuration
* Drop support for Symfony <3
## 3.3.1 (2018-11-04)
* Fixed compatiblity with Symfony 4.2
## 3.3.0 (2018-06-04)
* Fixed the autowiring of the channel logger in autoconfigured services
* Added timeouts to the pushover, hipchat, slack handlers
* Dropped support for PHP 5.3, 5.4, and HHVM
* Added configuration for HttpCodeActivationStrategy
* Deprecated "excluded_404s" option for Symfony >= 3.4
## 3.2.0 (2018-03-05)
* Removed randomness from the container build
* Fixed support for the `monolog.logger` tag specifying a channel in combination with Symfony 3.4+ autowiring
* Fixed visibility of channels configured explicitly in the bundle config (they are now public in Symfony 4 too)
* Fixed invalid service definitions
## 3.1.2 (2017-11-06)
* fix invalid usage of count()
## 3.1.1 (2017-09-26)
* added support for Symfony 4
## 3.1.0 (2017-03-26)
* Added support for server_log handler
* Allow configuring VERBOSITY_QUIET in console handlers
* Fixed autowiring
* Fixed slackbot handler not escaping channel names properly
* Fixed slackbot handler requiring `slack_team` instead of `team` to be configured
## 3.0.3 (2017-01-10)
* Fixed deprecation notices when using Symfony 3.3+ and PHP7+
## 3.0.2 (2017-01-03)
* Revert disabling DebugHandler in CLI environments
* Update configuration for slack handlers for Monolog 1.22 new options
* Revert the removal of the DebugHandlerPass (needed for Symfony <3.2)
## 3.0.1 (2016-11-15)
* Removed obsolete code (DebugHandlerPass)
## 3.0.0 (2016-11-06)
* Removed class parameters for the container configuration
* Bumped minimum version of supported Symfony version to 2.7
* Removed `NotFoundActivationStrategy` (the bundle now uses the class from MonologBridge)

View File

@@ -0,0 +1,70 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\MonologBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
/**
* Registers processors in Monolog loggers or handlers.
*
* @author Christophe Coevoet <stof@notk.org>
*
* @internalsince 3.9.0
*/
class AddProcessorsPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('monolog.logger')) {
return;
}
foreach ($container->findTaggedServiceIds('monolog.processor') as $id => $tags) {
foreach ($tags as $tag) {
if (!empty($tag['channel']) && !empty($tag['handler'])) {
throw new \InvalidArgumentException(sprintf('you cannot specify both the "handler" and "channel" attributes for the "monolog.processor" tag on service "%s"', $id));
}
if (!empty($tag['handler'])) {
$definition = $container->findDefinition(sprintf('monolog.handler.%s', $tag['handler']));
$parentDef = $definition;
while (!$parentDef->getClass() && $parentDef instanceof ChildDefinition) {
$parentDef = $container->findDefinition($parentDef->getParent());
}
$class = $container->getParameterBag()->resolveValue($parentDef->getClass());
if (!method_exists($class, 'pushProcessor')) {
throw new \InvalidArgumentException(sprintf('The "%s" handler does not accept processors', $tag['handler']));
}
} elseif (!empty($tag['channel'])) {
if ('app' === $tag['channel']) {
$definition = $container->getDefinition('monolog.logger');
} else {
$definition = $container->getDefinition(sprintf('monolog.logger.%s', $tag['channel']));
}
} else {
$definition = $container->getDefinition('monolog.logger_prototype');
}
if (!empty($tag['method'])) {
$processor = [new Reference($id), $tag['method']];
} else {
// If no method is defined, fallback to use __invoke
$processor = new Reference($id);
}
$definition->addMethodCall('pushProcessor', [$processor]);
}
}
}
}

View File

@@ -0,0 +1,59 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\MonologBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Reference;
/**
* Sets the transport for Swiftmailer handlers depending on the existing
* container definitions.
*
* @author Christian Flothmann <christian.flothmann@xabbuh.de>
*
* @internalsince 3.9.0
*/
class AddSwiftMailerTransportPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$handlers = $container->getParameter('monolog.swift_mailer.handlers');
foreach ($handlers as $id) {
$definition = $container->getDefinition($id);
$mailerId = (string) $definition->getArgument(0);
// Try to fetch the transport for a non-default mailer first, then go with the default swiftmailer
$possibleServices = [
$mailerId.'.transport.real',
$mailerId.'.transport',
'swiftmailer.transport.real',
'swiftmailer.transport',
];
foreach ($possibleServices as $serviceId) {
if ($container->hasAlias($serviceId) || $container->hasDefinition($serviceId)) {
$definition->addMethodCall(
'setTransport',
[new Reference($serviceId)]
);
break;
}
}
}
}
}

View File

@@ -0,0 +1,58 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\MonologBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Definition;
use Monolog\Logger;
/**
* Adds the DebugHandler when the profiler is enabled and kernel.debug is true.
*
* @author Christophe Coevoet <stof@notk.org>
* @author Jordi Boggiano <j.boggiano@seld.be>
*
* @deprecated since version 2.12, to be removed in 4.0. Use AddDebugLogProcessorPass in FrameworkBundle instead.
*/
class DebugHandlerPass implements CompilerPassInterface
{
private $channelPass;
public function __construct(LoggerChannelPass $channelPass)
{
@trigger_error('The '.__CLASS__.' class is deprecated since version 2.12 and will be removed in 4.0. Use AddDebugLogProcessorPass in FrameworkBundle instead.', E_USER_DEPRECATED);
$this->channelPass = $channelPass;
}
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('profiler')) {
return;
}
if (!$container->getParameter('kernel.debug')) {
return;
}
$debugHandler = new Definition('Symfony\Bridge\Monolog\Handler\DebugHandler', [Logger::DEBUG, true]);
$container->setDefinition('monolog.handler.debug', $debugHandler);
foreach ($this->channelPass->getChannels() as $channel) {
$container
->getDefinition($channel === 'app' ? 'monolog.logger' : 'monolog.logger.'.$channel)
->addMethodCall('pushHandler', [new Reference('monolog.handler.debug')]);
}
}
}

View File

@@ -0,0 +1,57 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\MonologBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
/**
* Fixes loggers with no handlers (by registering a "null" one).
*
* Monolog 1.x adds a default handler logging on STDERR when a logger has
* no registered handlers. This is NOT what what we want in Symfony, so in such
* cases, we add a "null" handler to avoid the issue.
*
* Note that Monolog 2.x does not register a default handler anymore, so this pass can
* be removed when MonologBundle minimum version of Monolog is bumped to 2.0.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @see https://github.com/Seldaek/monolog/commit/ad37b7b2d11f300cbace9f5e84f855d329519e28
*
* @internalsince 3.9.0
*/
class FixEmptyLoggerPass implements CompilerPassInterface
{
private $channelPass;
public function __construct(LoggerChannelPass $channelPass)
{
$this->channelPass = $channelPass;
}
public function process(ContainerBuilder $container)
{
$container->register('monolog.handler.null_internal', 'Monolog\Handler\NullHandler');
foreach ($this->channelPass->getChannels() as $channel) {
$def = $container->getDefinition($channel === 'app' ? 'monolog.logger' : 'monolog.logger.'.$channel);
foreach ($def->getMethodCalls() as $method) {
if ('pushHandler' === $method[0]) {
continue 2;
}
}
$def->addMethodCall('pushHandler', [new Reference('monolog.handler.null_internal')]);
}
}
}

View File

@@ -0,0 +1,161 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\MonologBundle\DependencyInjection\Compiler;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\Argument\BoundArgument;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Reference;
/**
* Replaces the default logger by another one with its own channel for tagged services.
*
* @author Christophe Coevoet <stof@notk.org>
*
* @internalsince 3.9.0
*/
class LoggerChannelPass implements CompilerPassInterface
{
protected $channels = ['app'];
/**
* {@inheritDoc}
*/
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('monolog.logger')) {
return;
}
// create channels necessary for the handlers
foreach ($container->findTaggedServiceIds('monolog.logger') as $id => $tags) {
foreach ($tags as $tag) {
if (empty($tag['channel']) || 'app' === $tag['channel']) {
continue;
}
$resolvedChannel = $container->getParameterBag()->resolveValue($tag['channel']);
$definition = $container->getDefinition($id);
$loggerId = sprintf('monolog.logger.%s', $resolvedChannel);
$this->createLogger($resolvedChannel, $loggerId, $container);
foreach ($definition->getArguments() as $index => $argument) {
if ($argument instanceof Reference && 'logger' === (string) $argument) {
$definition->replaceArgument($index, $this->changeReference($argument, $loggerId));
}
}
$calls = $definition->getMethodCalls();
foreach ($calls as $i => $call) {
foreach ($call[1] as $index => $argument) {
if ($argument instanceof Reference && 'logger' === (string) $argument) {
$calls[$i][1][$index] = $this->changeReference($argument, $loggerId);
}
}
}
$definition->setMethodCalls($calls);
$binding = new BoundArgument(new Reference($loggerId));
// Mark the binding as used already, to avoid reporting it as unused if the service does not use a
// logger injected through the LoggerInterface alias.
$values = $binding->getValues();
$values[2] = true;
$binding->setValues($values);
$bindings = $definition->getBindings();
$bindings['Psr\Log\LoggerInterface'] = $binding;
$definition->setBindings($bindings);
}
}
// create additional channels
foreach ($container->getParameter('monolog.additional_channels') as $chan) {
if ($chan === 'app') {
continue;
}
$loggerId = sprintf('monolog.logger.%s', $chan);
$this->createLogger($chan, $loggerId, $container);
$container->getDefinition($loggerId)->setPublic(true);
}
$container->getParameterBag()->remove('monolog.additional_channels');
// wire handlers to channels
$handlersToChannels = $container->getParameter('monolog.handlers_to_channels');
foreach ($handlersToChannels as $handler => $channels) {
foreach ($this->processChannels($channels) as $channel) {
try {
$logger = $container->getDefinition($channel === 'app' ? 'monolog.logger' : 'monolog.logger.'.$channel);
} catch (InvalidArgumentException $e) {
$msg = 'Monolog configuration error: The logging channel "'.$channel.'" assigned to the "'.substr($handler, 16).'" handler does not exist.';
throw new \InvalidArgumentException($msg, 0, $e);
}
$logger->addMethodCall('pushHandler', [new Reference($handler)]);
}
}
}
/**
* @return array
*/
public function getChannels()
{
return $this->channels;
}
/**
* @return array
*/
protected function processChannels(?array $configuration)
{
if (null === $configuration) {
return $this->channels;
}
if ('inclusive' === $configuration['type']) {
return $configuration['elements'] ?: $this->channels;
}
return array_diff($this->channels, $configuration['elements']);
}
/**
* Create new logger from the monolog.logger_prototype
*
* @return void
*/
protected function createLogger(string $channel, string $loggerId, ContainerBuilder $container)
{
if (!in_array($channel, $this->channels)) {
$logger = new ChildDefinition('monolog.logger_prototype');
$logger->replaceArgument(0, $channel);
$container->setDefinition($loggerId, $logger);
$this->channels[] = $channel;
}
$parameterName = $channel . 'Logger';
$container->registerAliasForArgument($loggerId, LoggerInterface::class, $parameterName);
}
/**
* Creates a copy of a reference and alters the service ID.
*/
private function changeReference(Reference $reference, string $serviceId): Reference
{
return new Reference($serviceId, $reference->getInvalidBehavior());
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
Copyright (c) 2004-2019 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,56 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\MonologBundle;
use Monolog\Formatter\JsonFormatter;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\HandlerInterface;
use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\AddSwiftMailerTransportPass;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\LoggerChannelPass;
use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\DebugHandlerPass;
use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\AddProcessorsPass;
use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\FixEmptyLoggerPass;
/**
* @author Jordi Boggiano <j.boggiano@seld.be>
*
* @finalsince 3.9.0
*/
class MonologBundle extends Bundle
{
/**
* @return void
*/
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass($channelPass = new LoggerChannelPass());
$container->addCompilerPass(new FixEmptyLoggerPass($channelPass));
$container->addCompilerPass(new AddProcessorsPass());
$container->addCompilerPass(new AddSwiftMailerTransportPass());
}
/**
* @internal
* @return void
*/
public static function includeStacktraces(HandlerInterface $handler)
{
$formatter = $handler->getFormatter();
if ($formatter instanceof LineFormatter || $formatter instanceof JsonFormatter) {
$formatter->includeStacktraces();
}
}
}

View File

@@ -0,0 +1,12 @@
MonologBundle
=============
The `MonologBundle` provides integration of the [Monolog](https://github.com/Seldaek/monolog)
library into the Symfony framework.
More information in the official [documentation](http://symfony.com/doc/current/cookbook/logging/index.html).
License
=======
This bundle is released under the [MIT license](LICENSE)

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="monolog.logger" parent="monolog.logger_prototype" public="false">
<argument index="0">app</argument>
<call method="useMicrosecondTimestamps">
<argument>%monolog.use_microseconds%</argument>
</call>
</service>
<service id="logger" alias="monolog.logger" />
<service id="Psr\Log\LoggerInterface" alias="logger" public="false" />
<service id="monolog.logger_prototype" class="Monolog\Logger" abstract="true">
<argument /><!-- Channel -->
</service>
<service id="monolog.activation_strategy.not_found" class="Symfony\Bridge\Monolog\Handler\FingersCrossed\NotFoundActivationStrategy" abstract="true" />
<service id="monolog.handler.fingers_crossed.error_level_activation_strategy" class="Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy" abstract="true" />
<!-- Formatters -->
<service id="monolog.formatter.chrome_php" class="Monolog\Formatter\ChromePHPFormatter" public="false" />
<service id="monolog.formatter.gelf_message" class="Monolog\Formatter\GelfMessageFormatter" public="false" />
<service id="monolog.formatter.html" class="Monolog\Formatter\HtmlFormatter" public="false" />
<service id="monolog.formatter.json" class="Monolog\Formatter\JsonFormatter" public="false" />
<service id="monolog.formatter.line" class="Monolog\Formatter\LineFormatter" public="false" />
<service id="monolog.formatter.loggly" class="Monolog\Formatter\LogglyFormatter" public="false" />
<service id="monolog.formatter.normalizer" class="Monolog\Formatter\NormalizerFormatter" public="false" />
<service id="monolog.formatter.scalar" class="Monolog\Formatter\ScalarFormatter" public="false" />
<service id="monolog.formatter.wildfire" class="Monolog\Formatter\WildfireFormatter" public="false" />
<service id="monolog.formatter.logstash" class="Monolog\Formatter\LogstashFormatter" public="false">
<argument index="0">app</argument>
</service>
<service id="monolog.http_client" class="Symfony\Contracts\HttpClient\HttpClientInterface" public="false">
<factory class="Symfony\Component\HttpClient\HttpClient" method="create" />
</service>
</services>
</container>

View File

@@ -0,0 +1,205 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns="http://symfony.com/schema/dic/monolog"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://symfony.com/schema/dic/monolog"
elementFormDefault="qualified">
<xsd:element name="config" type="config" />
<xsd:complexType name="config">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="handler" type="handler" />
<xsd:element name="channel" type="xsd:string" />
</xsd:choice>
</xsd:complexType>
<xsd:complexType name="handler">
<xsd:sequence>
<xsd:element name="email-prototype" type="email-prototype" minOccurs="0" maxOccurs="1" />
<xsd:element name="member" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="channels" type="channels" minOccurs="0" maxOccurs="1" />
<xsd:element name="publisher" type="publisher" minOccurs="0" maxOccurs="1" />
<xsd:element name="mongo" type="mongo" minOccurs="0" maxOccurs="1" />
<xsd:element name="elasticsearch" type="elasticsearch" minOccurs="0" maxOccurs="1" />
<xsd:element name="config" type="xsd:anyType" minOccurs="0" maxOccurs="1" />
<xsd:element name="excluded-404" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="excluded-http-code" type="excluded-http-code" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="tag" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="accepted-level" type="level" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="to-email" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="header" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="process-psr-3-messages" type="process-psr-3-messages" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="priority" type="xsd:integer" />
<xsd:attribute name="level" type="level" />
<xsd:attribute name="bubble" type="xsd:boolean" />
<xsd:attribute name="process-psr-3-messages" type="xsd:boolean" />
<xsd:attribute name="use_locking" type="xsd:boolean" />
<xsd:attribute name="app-name" type="xsd:string" />
<xsd:attribute name="path" type="xsd:string" />
<xsd:attribute name="id" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" use="required" />
<xsd:attribute name="ident" type="xsd:string" />
<xsd:attribute name="facility" type="xsd:string" />
<xsd:attribute name="host" type="xsd:string" />
<xsd:attribute name="source" type="xsd:string" />
<xsd:attribute name="port" type="xsd:integer" />
<xsd:attribute name="action-level" type="level" />
<xsd:attribute name="passthru-level" type="level" />
<xsd:attribute name="min-level" type="level" />
<xsd:attribute name="max-level" type="level" />
<xsd:attribute name="buffer-size" type="xsd:integer" />
<xsd:attribute name="flush-on-overflow" type="xsd:boolean" />
<xsd:attribute name="max-files" type="xsd:integer" />
<xsd:attribute name="handler" type="xsd:string" />
<xsd:attribute name="from-email" type="xsd:string" />
<xsd:attribute name="to-email" type="xsd:string" />
<xsd:attribute name="subject" type="xsd:string" />
<xsd:attribute name="notify" type="xsd:boolean" />
<xsd:attribute name="room" type="xsd:string" />
<xsd:attribute name="nickname" type="xsd:string" />
<xsd:attribute name="release" type="xsd:string" />
<xsd:attribute name="timeout" type="xsd:string" />
<xsd:attribute name="time" type="xsd:integer" />
<xsd:attribute name="store" type="xsd:string" />
<xsd:attribute name="deduplication-level" type="level" />
<xsd:attribute name="connection-timeout" type="xsd:string" />
<xsd:attribute name="persistent" type="xsd:boolean" />
<xsd:attribute name="dsn" type="xsd:string" />
<xsd:attribute name="hub-id" type="xsd:string" />
<xsd:attribute name="client-id" type="xsd:string" />
<xsd:attribute name="use-ssl" type="xsd:boolean" />
<xsd:attribute name="formatter" type="xsd:string" />
<xsd:attribute name="token" type="xsd:string" />
<xsd:attribute name="channel" type="xsd:string" />
<xsd:attribute name="bot-name" type="xsd:string" />
<xsd:attribute name="use-attachment" type="xsd:boolean" />
<xsd:attribute name="use-short-attachment" type="xsd:boolean" />
<xsd:attribute name="include-extra" type="xsd:boolean" />
<xsd:attribute name="icon-emoji" type="xsd:string" />
<xsd:attribute name="file-permission" type="xsd:string" />
<xsd:attribute name="filename-format" type="xsd:string" />
<xsd:attribute name="date-format" type="xsd:string" />
<xsd:attribute name="index" type="xsd:string" />
<xsd:attribute name="document_type" type="xsd:string" />
<xsd:attribute name="document-type" type="xsd:string" />
<xsd:attribute name="ignore-error" type="xsd:string" />
<xsd:attribute name="api_version" type="xsd:string" />
<xsd:attribute name="include-stacktraces" type="xsd:string" />
<xsd:attribute name="content-type" type="xsd:string" />
<xsd:attribute name="webhook-url" type="xsd:string" />
<xsd:attribute name="slack-team" type="xsd:string" />
<xsd:attribute name="region" type="xsd:string" />
</xsd:complexType>
<xsd:simpleType name="level">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="debug" />
<xsd:enumeration value="info" />
<xsd:enumeration value="notice" />
<xsd:enumeration value="warning" />
<xsd:enumeration value="error" />
<xsd:enumeration value="critical" />
<xsd:enumeration value="alert" />
<xsd:enumeration value="emergency" />
<xsd:enumeration value="DEBUG" />
<xsd:enumeration value="INFO" />
<xsd:enumeration value="NOTICE" />
<xsd:enumeration value="WARNING" />
<xsd:enumeration value="ERROR" />
<xsd:enumeration value="CRITICAL" />
<xsd:enumeration value="ALERT" />
<xsd:enumeration value="EMERGENCY" />
<xsd:enumeration value="100" />
<xsd:enumeration value="200" />
<xsd:enumeration value="250" />
<xsd:enumeration value="300" />
<xsd:enumeration value="400" />
<xsd:enumeration value="500" />
<xsd:enumeration value="550" />
<xsd:enumeration value="600" />
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="publisher">
<xsd:attribute name="id" type="xsd:string" />
<xsd:attribute name="hostname" type="xsd:string" />
<xsd:attribute name="port" type="xsd:integer" />
<xsd:attribute name="chunk_size" type="xsd:integer" />
</xsd:complexType>
<xsd:complexType name="email-prototype">
<xsd:attribute name="id" type="xsd:string" />
<xsd:attribute name="method" type="xsd:string" />
</xsd:complexType>
<xsd:complexType name="channels">
<xsd:sequence>
<xsd:element name="channel" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="type" type="channel_type" />
</xsd:complexType>
<xsd:simpleType name="channel_type">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="inclusive" />
<xsd:enumeration value="exclusive" />
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="mongo">
<xsd:attribute name="id" type="xsd:string" />
<xsd:attribute name="host" type="xsd:string" />
<xsd:attribute name="port" type="xsd:integer" />
<xsd:attribute name="user" type="xsd:string" />
<xsd:attribute name="pass" type="xsd:string" />
<xsd:attribute name="database" type="xsd:string" />
<xsd:attribute name="collection" type="xsd:string" />
</xsd:complexType>
<xsd:complexType name="redis">
<xsd:attribute name="id" type="xsd:string" />
<xsd:attribute name="host" type="xsd:string" />
<xsd:attribute name="password" type="xsd:string" />
<xsd:attribute name="port" type="xsd:integer" />
<xsd:attribute name="database" type="xsd:integer" />
<xsd:attribute name="key_name" type="xsd:string" />
</xsd:complexType>
<xsd:complexType name="predis">
<xsd:attribute name="id" type="xsd:string" />
<xsd:attribute name="host" type="xsd:string" />
</xsd:complexType>
<xsd:complexType name="elasticsearch">
<xsd:attribute name="id" type="xsd:string" />
<xsd:attribute name="host" type="xsd:string" />
<xsd:attribute name="port" type="xsd:integer" />
<xsd:attribute name="transport" type="xsd:string" />
<xsd:attribute name="user" type="xsd:string" />
<xsd:attribute name="password" type="xsd:string" />
</xsd:complexType>
<xsd:complexType name="excluded-http-code">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="url" type="xsd:string" />
</xsd:choice>
<xsd:attribute name="code" type="xsd:integer" />
</xsd:complexType>
<xsd:complexType name="headers">
<xsd:sequence>
<xsd:any minOccurs="0" processContents="lax" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="process-psr-3-messages">
<xsd:attribute name="enabled" type="xsd:boolean" />
<xsd:attribute name="date-format" type="xsd:string" />
<xsd:attribute name="remove-used-context-fields" type="xsd:boolean" />
</xsd:complexType>
</xsd:schema>

View File

@@ -0,0 +1,61 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\MonologBundle\SwiftMailer;
/**
* Helps create Swift_Message objects, lazily
*
* @author Ryan Weaver <ryan@knpuniversity.com>
*/
class MessageFactory
{
private $mailer;
private $fromEmail;
private $toEmail;
private $subject;
private $contentType;
public function __construct(\Swift_Mailer $mailer, $fromEmail, $toEmail, $subject, $contentType = null)
{
$this->mailer = $mailer;
$this->fromEmail = $fromEmail;
$this->toEmail = $toEmail;
$this->subject = $subject;
$this->contentType = $contentType;
}
/**
* Creates a Swift_Message template that will be used to send the log message
*
* @param string $content formatted email body to be sent
* @param array $records Log records that formed the content
* @return \Swift_Message
*/
public function createMessage($content, array $records)
{
/** @var \Swift_Message $message */
$message = $this->mailer->createMessage();
$message->setTo($this->toEmail);
$message->setFrom($this->fromEmail);
$message->setSubject($this->subject);
if ($this->contentType) {
$message->setContentType($this->contentType);
}
return $message;
}
}

View File

@@ -0,0 +1,42 @@
{
"name": "symfony/monolog-bundle",
"type": "symfony-bundle",
"description": "Symfony MonologBundle",
"keywords": ["log", "logging"],
"homepage": "https://symfony.com",
"license": "MIT",
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"require": {
"php": ">=7.2.5",
"symfony/monolog-bridge": "^5.4 || ^6.0 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
"symfony/config": "^5.4 || ^6.0 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.0 || ^7.0",
"monolog/monolog": "^1.25.1 || ^2.0 || ^3.0"
},
"require-dev": {
"symfony/yaml": "^5.4 || ^6.0 || ^7.0",
"symfony/console": "^5.4 || ^6.0 || ^7.0",
"symfony/phpunit-bridge": "^6.3 || ^7.0"
},
"autoload": {
"psr-4": { "Symfony\\Bundle\\MonologBundle\\": "" },
"exclude-from-classmap": [
"/Tests/"
]
},
"extra": {
"branch-alias": {
"dev-master": "3.x-dev"
}
}
}