@@ -383,6 +383,8 @@ public function getConfigTreeBuilder()
383
383
$ treeBuilder = new TreeBuilder ('monolog ' );
384
384
$ rootNode = method_exists (TreeBuilder::class, 'getRootNode ' ) ? $ treeBuilder ->getRootNode () : $ treeBuilder ->root ('monolog ' );
385
385
386
+ $ this ->addChannelsSection ($ rootNode , 'handler_default_channels ' );
387
+
386
388
$ handlers = $ rootNode
387
389
->fixXmlConfig ('channel ' )
388
390
->fixXmlConfig ('handler ' )
@@ -621,6 +623,7 @@ public function getConfigTreeBuilder()
621
623
->end ()
622
624
->scalarNode ('formatter ' )->end ()
623
625
->booleanNode ('nested ' )->defaultFalse ()->end ()
626
+ ->booleanNode ('use_default_channels ' )->defaultTrue ()->end ()
624
627
->end ();
625
628
626
629
$ this ->addGelfSection ($ handlerNode );
@@ -793,9 +796,9 @@ public function getConfigTreeBuilder()
793
796
return $ treeBuilder ;
794
797
}
795
798
796
- private function addGelfSection (ArrayNodeDefinition $ handerNode )
799
+ private function addGelfSection (ArrayNodeDefinition $ handlerNode )
797
800
{
798
- $ handerNode
801
+ $ handlerNode
799
802
->children ()
800
803
->arrayNode ('publisher ' )
801
804
->canBeUnset ()
@@ -824,9 +827,9 @@ private function addGelfSection(ArrayNodeDefinition $handerNode)
824
827
;
825
828
}
826
829
827
- private function addMongoSection (ArrayNodeDefinition $ handerNode )
830
+ private function addMongoSection (ArrayNodeDefinition $ handlerNode )
828
831
{
829
- $ handerNode
832
+ $ handlerNode
830
833
->children ()
831
834
->arrayNode ('mongo ' )
832
835
->canBeUnset ()
@@ -864,9 +867,9 @@ private function addMongoSection(ArrayNodeDefinition $handerNode)
864
867
;
865
868
}
866
869
867
- private function addElasticsearchSection (ArrayNodeDefinition $ handerNode )
870
+ private function addElasticsearchSection (ArrayNodeDefinition $ handlerNode )
868
871
{
869
- $ handerNode
872
+ $ handlerNode
870
873
->children ()
871
874
->arrayNode ('elasticsearch ' )
872
875
->canBeUnset ()
@@ -896,9 +899,9 @@ private function addElasticsearchSection(ArrayNodeDefinition $handerNode)
896
899
;
897
900
}
898
901
899
- private function addRedisSection (ArrayNodeDefinition $ handerNode )
902
+ private function addRedisSection (ArrayNodeDefinition $ handlerNode )
900
903
{
901
- $ handerNode
904
+ $ handlerNode
902
905
->children ()
903
906
->arrayNode ('redis ' )
904
907
->canBeUnset ()
@@ -929,9 +932,9 @@ private function addRedisSection(ArrayNodeDefinition $handerNode)
929
932
;
930
933
}
931
934
932
- private function addPredisSection (ArrayNodeDefinition $ handerNode )
935
+ private function addPredisSection (ArrayNodeDefinition $ handlerNode )
933
936
{
934
- $ handerNode
937
+ $ handlerNode
935
938
->children ()
936
939
->arrayNode ('predis ' )
937
940
->canBeUnset ()
@@ -958,9 +961,9 @@ private function addPredisSection(ArrayNodeDefinition $handerNode)
958
961
;
959
962
}
960
963
961
- private function addMailerSection (ArrayNodeDefinition $ handerNode )
964
+ private function addMailerSection (ArrayNodeDefinition $ handlerNode )
962
965
{
963
- $ handerNode
966
+ $ handlerNode
964
967
->children ()
965
968
->scalarNode ('from_email ' )->end () // swift_mailer, native_mailer, symfony_mailer and flowdock
966
969
->arrayNode ('to_email ' ) // swift_mailer, native_mailer and symfony_mailer
@@ -1005,9 +1008,9 @@ private function addMailerSection(ArrayNodeDefinition $handerNode)
1005
1008
;
1006
1009
}
1007
1010
1008
- private function addVerbosityLevelSection (ArrayNodeDefinition $ handerNode )
1011
+ private function addVerbosityLevelSection (ArrayNodeDefinition $ handlerNode )
1009
1012
{
1010
- $ handerNode
1013
+ $ handlerNode
1011
1014
->children ()
1012
1015
->arrayNode ('verbosity_levels ' ) // console
1013
1016
->beforeNormalization ()
@@ -1071,11 +1074,11 @@ private function addVerbosityLevelSection(ArrayNodeDefinition $handerNode)
1071
1074
;
1072
1075
}
1073
1076
1074
- private function addChannelsSection (ArrayNodeDefinition $ handerNode )
1077
+ private function addChannelsSection (ArrayNodeDefinition $ handlerNode , string $ nodeName = ' channels ' )
1075
1078
{
1076
- $ handerNode
1079
+ $ handlerNode
1077
1080
->children ()
1078
- ->arrayNode (' channels ' )
1081
+ ->arrayNode ($ nodeName )
1079
1082
->fixXmlConfig ('channel ' , 'elements ' )
1080
1083
->canBeUnset ()
1081
1084
->beforeNormalization ()
@@ -1091,7 +1094,7 @@ private function addChannelsSection(ArrayNodeDefinition $handerNode)
1091
1094
->thenUnset ()
1092
1095
->end ()
1093
1096
->validate ()
1094
- ->always (function ($ v ) {
1097
+ ->always (function ($ v ) use ( $ nodeName ) {
1095
1098
$ isExclusive = null ;
1096
1099
if (isset ($ v ['type ' ])) {
1097
1100
$ isExclusive = 'exclusive ' === $ v ['type ' ];
@@ -1101,13 +1104,13 @@ private function addChannelsSection(ArrayNodeDefinition $handerNode)
1101
1104
foreach ($ v ['elements ' ] as $ element ) {
1102
1105
if (0 === strpos ($ element , '! ' )) {
1103
1106
if (false === $ isExclusive ) {
1104
- throw new InvalidConfigurationException ('Cannot combine exclusive/inclusive definitions in channels list. ' );
1107
+ throw new InvalidConfigurationException (sprintf ( 'Cannot combine exclusive/inclusive definitions in %s list. ' , $ nodeName ) );
1105
1108
}
1106
1109
$ elements [] = substr ($ element , 1 );
1107
1110
$ isExclusive = true ;
1108
1111
} else {
1109
1112
if (true === $ isExclusive ) {
1110
- throw new InvalidConfigurationException ('Cannot combine exclusive/inclusive definitions in channels list ' );
1113
+ throw new InvalidConfigurationException (sprintf ( 'Cannot combine exclusive/inclusive definitions in %s list ' , $ nodeName ) );
1111
1114
}
1112
1115
$ elements [] = $ element ;
1113
1116
$ isExclusive = false ;
@@ -1126,7 +1129,7 @@ private function addChannelsSection(ArrayNodeDefinition $handerNode)
1126
1129
->scalarNode ('type ' )
1127
1130
->validate ()
1128
1131
->ifNotInArray (['inclusive ' , 'exclusive ' ])
1129
- ->thenInvalid ('The type of channels has to be inclusive or exclusive ' )
1132
+ ->thenInvalid (sprintf ( 'The type of %s has to be inclusive or exclusive ' , $ nodeName ) )
1130
1133
->end ()
1131
1134
->end ()
1132
1135
->arrayNode ('elements ' )
0 commit comments