@@ -35,6 +35,7 @@ public static Command CreateFormatCommand()
3535 formatCommand . AddOption ( writeStdoutOption ) ;
3636 formatCommand . AddOption ( CompilationErrorsAsWarningsOption ) ;
3737 formatCommand . AddOption ( ConfigPathOption ) ;
38+ formatCommand . AddOption ( LogFormatOption ) ;
3839 formatCommand . AddOption ( LogLevelOption ) ;
3940
4041 formatCommand . SetHandler ( async context =>
@@ -51,6 +52,7 @@ public static Command CreateFormatCommand()
5152 ) ;
5253 var configPath = context . ParseResult . GetValueForOption ( ConfigPathOption ) ;
5354 var logLevel = context . ParseResult . GetValueForOption ( LogLevelOption ) ;
55+ var logFormat = context . ParseResult . GetValueForOption ( LogFormatOption ) ;
5456 var token = context . GetCancellationToken ( ) ;
5557
5658 context . ExitCode = await FormatOrCheck (
@@ -65,6 +67,7 @@ public static Command CreateFormatCommand()
6567 compilationErrorsAsWarnings ,
6668 configPath ,
6769 logLevel ,
70+ logFormat ,
6871 token
6972 ) ;
7073 } ) ;
@@ -81,6 +84,7 @@ public static Command CreateCheckCommand()
8184 var directoryOrFileArgument = AddDirectoryOrFileArgument ( checkCommand ) ;
8285
8386 checkCommand . AddOption ( ConfigPathOption ) ;
87+ checkCommand . AddOption ( LogFormatOption ) ;
8488 checkCommand . AddOption ( LogLevelOption ) ;
8589 checkCommand . AddOption ( IncludeGeneratedOption ) ;
8690 checkCommand . AddOption ( NoMsBuildCheckOption ) ;
@@ -96,6 +100,7 @@ public static Command CreateCheckCommand()
96100 ) ;
97101 var configPath = context . ParseResult . GetValueForOption ( ConfigPathOption ) ;
98102 var logLevel = context . ParseResult . GetValueForOption ( LogLevelOption ) ;
103+ var logFormat = context . ParseResult . GetValueForOption ( LogFormatOption ) ;
99104 var token = context . GetCancellationToken ( ) ;
100105
101106 context . ExitCode = await FormatOrCheck (
@@ -110,6 +115,7 @@ public static Command CreateCheckCommand()
110115 compilationErrorsAsWarnings ,
111116 configPath ,
112117 logLevel ,
118+ logFormat ,
113119 token
114120 ) ;
115121 } ) ;
@@ -129,11 +135,12 @@ private static async Task<int> FormatOrCheck(
129135 bool compilationErrorsAsWarnings ,
130136 string ? configPath ,
131137 LogLevel logLevel ,
138+ LogFormat logFormat ,
132139 CancellationToken cancellationToken
133140 )
134141 {
135142 var console = new SystemConsole ( ) ;
136- var logger = new ConsoleLogger ( console , logLevel ) ;
143+ var logger = new ConsoleLogger ( console , logLevel , logFormat ) ;
137144
138145 var directoryOrFileNotProvided = directoryOrFile is null or { Length : 0 } ;
139146 var originalDirectoryOrFile = directoryOrFile ;
@@ -210,8 +217,18 @@ private static Argument<string[]> AddDirectoryOrFileArgument(Command command)
210217 "Path to the CSharpier configuration file"
211218 ) ;
212219
220+ private static readonly Option < LogFormat > LogFormatOption = new (
221+ [ "--log-format" ] ,
222+ ( ) => LogFormat . Console ,
223+ """
224+ Log output format
225+ Console (default) - Formats messages in a human readable way for console interaction.
226+ MsBuild - Formats messages in standard error/warning format for MSBuild.
227+ """
228+ ) ;
229+
213230 private static readonly Option < LogLevel > LogLevelOption = new (
214- [ "--loglevel " ] ,
231+ [ "--log-level " ] ,
215232 ( ) => LogLevel . Information ,
216233 "Specify the log level - Debug, Information (default), Warning, Error, None"
217234 ) ;
0 commit comments