@@ -47,31 +47,16 @@ public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
4747 logEvent . AddPropertyIfAbsent ( logFilePathProp ) ;
4848 }
4949
50- /// <summary>
51- /// Configures the logging enricher with the specified log file path and verbosity.
52- /// </summary>
53- /// <param name="logFile">The log file path, or null to disable file logging.</param>
54- /// <param name="verbosity">The verbosity level.</param>
55- /// <param name="enableConsoleOutput">Whether to enable console output. When false, console output is suppressed.</param>
56- public static void Configure ( string ? logFile , Verbosity verbosity , bool enableConsoleOutput = true )
50+ public static void Configure ( GitVersionOptions gitVersionOptions )
5751 {
58- if ( ! string . IsNullOrWhiteSpace ( logFile ) )
59- logFilePath = logFile ;
60- LogLevelSwitch . MinimumLevel = GetLevelForVerbosity ( verbosity ) ;
61- IsConsoleEnabled = enableConsoleOutput ;
62- }
52+ var enableConsoleOutput = gitVersionOptions . Output . Contains ( OutputType . BuildServer )
53+ || string . Equals ( gitVersionOptions . LogFilePath , "console" , StringComparison . OrdinalIgnoreCase ) ;
6354
64- /// <summary>
65- /// Configures the logging enricher with the specified log file path and log level.
66- /// </summary>
67- /// <param name="logFile">The log file path, or null to disable file logging.</param>
68- /// <param name="logLevel">The Microsoft.Extensions.Logging log level.</param>
69- /// <param name="enableConsoleOutput">Whether to enable console output. When false, console output is suppressed.</param>
70- public static void Configure ( string ? logFile , LogLevel logLevel , bool enableConsoleOutput = true )
71- {
72- if ( ! string . IsNullOrWhiteSpace ( logFile ) )
73- logFilePath = logFile ;
74- LogLevelSwitch . MinimumLevel = GetLevelForLogLevel ( logLevel ) ;
55+ if ( ! string . IsNullOrWhiteSpace ( gitVersionOptions . LogFilePath ) )
56+ {
57+ logFilePath = gitVersionOptions . LogFilePath ;
58+ }
59+ LogLevelSwitch . MinimumLevel = GetLevelForVerbosity ( gitVersionOptions . Verbosity ) ;
7560 IsConsoleEnabled = enableConsoleOutput ;
7661 }
7762
@@ -85,15 +70,4 @@ public static void Configure(string? logFile, LogLevel logLevel, bool enableCons
8570 { Verbosity . Minimal , LogEventLevel . Warning } ,
8671 { Verbosity . Quiet , LogEventLevel . Error }
8772 } ;
88-
89- private static LogEventLevel GetLevelForLogLevel ( LogLevel logLevel ) => logLevel switch
90- {
91- LogLevel . Trace => LogEventLevel . Verbose ,
92- LogLevel . Debug => LogEventLevel . Debug ,
93- LogLevel . Information => LogEventLevel . Information ,
94- LogLevel . Warning => LogEventLevel . Warning ,
95- LogLevel . Error => LogEventLevel . Error ,
96- LogLevel . Critical or LogLevel . None => LogEventLevel . Fatal ,
97- _ => LogEventLevel . Information
98- } ;
9973}
0 commit comments