1- namespace J4JSoftware . Configuration . CommandLine
1+ using System ;
2+ using J4JSoftware . Logging ;
3+
4+ namespace J4JSoftware . Configuration . CommandLine
25{
36 public class Parser
47 {
5- private readonly CommandLineLogger _logger ;
8+ private readonly IJ4JLogger ? _logger ;
69 private readonly ITokenizer _tokenizer ;
710
811 public Parser (
9- CommandLineLogger logger ,
10- CommandLineStyle style = CommandLineStyle . Windows
12+ CommandLineStyle style = CommandLineStyle . Windows ,
13+ Func < IJ4JLogger > ? loggerFactory = null
1114 )
12- : this ( new OptionCollectionNG ( style ) , logger )
15+ : this ( new OptionCollectionNG ( style ) , loggerFactory )
1316 {
1417 }
1518
1619 public Parser (
1720 IOptionCollection options ,
18- CommandLineLogger logger
21+ Func < IJ4JLogger > ? loggerFactory = null
1922 )
2023 : this (
2124 options ,
22- new Tokenizer ( logger , options . CommandLineStyle , options . MasterText . TextComparison ) ,
23- new ParsingTable ( options , logger ) ,
24- logger )
25+ new Tokenizer ( options . CommandLineStyle , options . MasterText . TextComparison , loggerFactory ) ,
26+ new ParsingTable ( options , loggerFactory ) ,
27+ loggerFactory ? . Invoke ( ) )
2528 {
2629 }
2730
2831 public Parser (
2932 IOptionCollection options ,
3033 ITokenizer tokenizer ,
3134 IParsingTable parsingTable ,
32- CommandLineLogger logger
35+ IJ4JLogger ? logger = null
3336 )
3437 {
3538 Options = options ;
@@ -45,7 +48,7 @@ public bool Parse( string cmdLine )
4548 {
4649 if ( ! ParsingTable . IsValid )
4750 {
48- _logger . LogError ( "ParsingTable is invalid" ) ;
51+ _logger ? . Error ( "ParsingTable is invalid" ) ;
4952 return false ;
5053 }
5154
0 commit comments