@@ -386,6 +386,8 @@ public function getConfigTreeBuilder(): TreeBuilder
386
386
$ treeBuilder = new TreeBuilder ('monolog ' );
387
387
$ rootNode = $ treeBuilder ->getRootNode ();
388
388
389
+ $ this ->addChannelsSection ($ rootNode , 'handler_default_channels ' );
390
+
389
391
$ handlers = $ rootNode
390
392
->fixXmlConfig ('channel ' )
391
393
->fixXmlConfig ('handler ' )
@@ -625,6 +627,7 @@ public function getConfigTreeBuilder(): TreeBuilder
625
627
->end ()
626
628
->scalarNode ('formatter ' )->end ()
627
629
->booleanNode ('nested ' )->defaultFalse ()->end ()
630
+ ->booleanNode ('use_default_channels ' )->defaultTrue ()->end ()
628
631
->end ();
629
632
630
633
$ this ->addGelfSection ($ handlerNode );
@@ -801,9 +804,9 @@ public function getConfigTreeBuilder(): TreeBuilder
801
804
return $ treeBuilder ;
802
805
}
803
806
804
- private function addGelfSection (ArrayNodeDefinition $ handerNode )
807
+ private function addGelfSection (ArrayNodeDefinition $ handlerNode )
805
808
{
806
- $ handerNode
809
+ $ handlerNode
807
810
->children ()
808
811
->arrayNode ('publisher ' )
809
812
->canBeUnset ()
@@ -832,9 +835,9 @@ private function addGelfSection(ArrayNodeDefinition $handerNode)
832
835
;
833
836
}
834
837
835
- private function addMongoSection (ArrayNodeDefinition $ handerNode )
838
+ private function addMongoSection (ArrayNodeDefinition $ handlerNode )
836
839
{
837
- $ handerNode
840
+ $ handlerNode
838
841
->children ()
839
842
->arrayNode ('mongo ' )
840
843
->canBeUnset ()
@@ -872,9 +875,9 @@ private function addMongoSection(ArrayNodeDefinition $handerNode)
872
875
;
873
876
}
874
877
875
- private function addElasticsearchSection (ArrayNodeDefinition $ handerNode )
878
+ private function addElasticsearchSection (ArrayNodeDefinition $ handlerNode )
876
879
{
877
- $ handerNode
880
+ $ handlerNode
878
881
->children ()
879
882
->arrayNode ('elasticsearch ' )
880
883
->canBeUnset ()
@@ -904,9 +907,9 @@ private function addElasticsearchSection(ArrayNodeDefinition $handerNode)
904
907
;
905
908
}
906
909
907
- private function addRedisSection (ArrayNodeDefinition $ handerNode )
910
+ private function addRedisSection (ArrayNodeDefinition $ handlerNode )
908
911
{
909
- $ handerNode
912
+ $ handlerNode
910
913
->children ()
911
914
->arrayNode ('redis ' )
912
915
->canBeUnset ()
@@ -937,9 +940,9 @@ private function addRedisSection(ArrayNodeDefinition $handerNode)
937
940
;
938
941
}
939
942
940
- private function addPredisSection (ArrayNodeDefinition $ handerNode )
943
+ private function addPredisSection (ArrayNodeDefinition $ handlerNode )
941
944
{
942
- $ handerNode
945
+ $ handlerNode
943
946
->children ()
944
947
->arrayNode ('predis ' )
945
948
->canBeUnset ()
@@ -966,9 +969,9 @@ private function addPredisSection(ArrayNodeDefinition $handerNode)
966
969
;
967
970
}
968
971
969
- private function addMailerSection (ArrayNodeDefinition $ handerNode )
972
+ private function addMailerSection (ArrayNodeDefinition $ handlerNode )
970
973
{
971
- $ handerNode
974
+ $ handlerNode
972
975
->children ()
973
976
->scalarNode ('from_email ' )->end () // swift_mailer, native_mailer, symfony_mailer and flowdock
974
977
->arrayNode ('to_email ' ) // swift_mailer, native_mailer and symfony_mailer
@@ -1013,9 +1016,9 @@ private function addMailerSection(ArrayNodeDefinition $handerNode)
1013
1016
;
1014
1017
}
1015
1018
1016
- private function addVerbosityLevelSection (ArrayNodeDefinition $ handerNode )
1019
+ private function addVerbosityLevelSection (ArrayNodeDefinition $ handlerNode )
1017
1020
{
1018
- $ handerNode
1021
+ $ handlerNode
1019
1022
->children ()
1020
1023
->arrayNode ('verbosity_levels ' ) // console
1021
1024
->beforeNormalization ()
@@ -1073,11 +1076,11 @@ private function addVerbosityLevelSection(ArrayNodeDefinition $handerNode)
1073
1076
;
1074
1077
}
1075
1078
1076
- private function addChannelsSection (ArrayNodeDefinition $ handerNode )
1079
+ private function addChannelsSection (ArrayNodeDefinition $ handlerNode , string $ nodeName = ' channels ' )
1077
1080
{
1078
- $ handerNode
1081
+ $ handlerNode
1079
1082
->children ()
1080
- ->arrayNode (' channels ' )
1083
+ ->arrayNode ($ nodeName )
1081
1084
->fixXmlConfig ('channel ' , 'elements ' )
1082
1085
->canBeUnset ()
1083
1086
->beforeNormalization ()
@@ -1093,7 +1096,7 @@ private function addChannelsSection(ArrayNodeDefinition $handerNode)
1093
1096
->thenUnset ()
1094
1097
->end ()
1095
1098
->validate ()
1096
- ->always (function ($ v ) {
1099
+ ->always (function ($ v ) use ( $ nodeName ) {
1097
1100
$ isExclusive = null ;
1098
1101
if (isset ($ v ['type ' ])) {
1099
1102
$ isExclusive = 'exclusive ' === $ v ['type ' ];
@@ -1103,13 +1106,13 @@ private function addChannelsSection(ArrayNodeDefinition $handerNode)
1103
1106
foreach ($ v ['elements ' ] as $ element ) {
1104
1107
if (0 === strpos ($ element , '! ' )) {
1105
1108
if (false === $ isExclusive ) {
1106
- throw new InvalidConfigurationException ('Cannot combine exclusive/inclusive definitions in channels list. ' );
1109
+ throw new InvalidConfigurationException (\sprintf ( 'Cannot combine exclusive/inclusive definitions in %s list. ' , $ nodeName ) );
1107
1110
}
1108
1111
$ elements [] = substr ($ element , 1 );
1109
1112
$ isExclusive = true ;
1110
1113
} else {
1111
1114
if (true === $ isExclusive ) {
1112
- throw new InvalidConfigurationException ('Cannot combine exclusive/inclusive definitions in channels list ' );
1115
+ throw new InvalidConfigurationException (\sprintf ( 'Cannot combine exclusive/inclusive definitions in %s list ' , $ nodeName ) );
1113
1116
}
1114
1117
$ elements [] = $ element ;
1115
1118
$ isExclusive = false ;
@@ -1128,7 +1131,7 @@ private function addChannelsSection(ArrayNodeDefinition $handerNode)
1128
1131
->scalarNode ('type ' )
1129
1132
->validate ()
1130
1133
->ifNotInArray (['inclusive ' , 'exclusive ' ])
1131
- ->thenInvalid ('The type of channels has to be inclusive or exclusive ' )
1134
+ ->thenInvalid (\sprintf ( 'The type of %s has to be inclusive or exclusive ' , $ nodeName ) )
1132
1135
->end ()
1133
1136
->end ()
1134
1137
->arrayNode ('elements ' )
0 commit comments