@@ -35,16 +35,15 @@ public abstract class BaseLog
3535 /// </param>
3636 /// <param name="parameters">Values of parameters in <paramref name="messageId"/> (resource string or message itself).</param>
3737 /// <returns><see cref="IDisposable"/> object. Region will closed by disposing of this object.</returns>
38- public IndentManager . IndentScope DebugRegion ( string messageId , params object [ ] parameters )
38+ public IndentManager . IndentScope DebugRegion ( string messageId , params ReadOnlySpan < object > parameters )
3939 {
4040 ArgumentNullException . ThrowIfNull ( messageId , "message" ) ;
4141 if ( ! IsLogged ( LogLevel . Debug ) )
4242 return IndentManager . IncreaseIndent ( ) ;
4343 var message = Strings . ResourceManager . GetString ( messageId , Strings . Culture ) ?? messageId ;
44- var title = parameters != null ? string . Format ( message , parameters ) : message ;
45- var titleParams = new object [ ] { title } ;
46- Debug ( nameof ( Strings . LogRegionBegin ) , titleParams ) ;
47- return IndentManager . IncreaseIndent ( ( ) => Debug ( nameof ( Strings . LogRegionEnd ) , titleParams ) ) ;
44+ var title = parameters . Length > 0 ? string . Format ( message , parameters ) : message ;
45+ Debug ( nameof ( Strings . LogRegionBegin ) , [ title ] ) ;
46+ return IndentManager . IncreaseIndent ( ( ) => Debug ( nameof ( Strings . LogRegionEnd ) , [ title ] ) ) ;
4847 }
4948
5049 /// <summary>
@@ -58,13 +57,13 @@ public IndentManager.IndentScope DebugRegion(string messageId, params object[] p
5857 /// Values of parameters in <paramref name="messageId"/> (resource string or message itself).
5958 /// </param>
6059 /// <returns><see cref="IDisposable"/> object. Region will closed by disposing of this object.</returns>
61- public IndentManager . IndentScope InfoRegion ( string messageId , params object [ ] parameters )
60+ public IndentManager . IndentScope InfoRegion ( string messageId , params ReadOnlySpan < object > parameters )
6261 {
6362 ArgumentNullException . ThrowIfNull ( messageId , "message" ) ;
6463 if ( ! IsLogged ( LogLevel . Info ) )
6564 return IndentManager . IncreaseIndent ( ) ;
6665 var message = Strings . ResourceManager . GetString ( messageId , Strings . Culture ) ?? messageId ;
67- var title = parameters != null ? string . Format ( message , parameters ) : message ;
66+ var title = parameters . Length > 0 ? string . Format ( message , parameters ) : message ;
6867 Info ( string . Format ( Strings . LogRegionBegin , title ) ) ;
6968 return IndentManager . IncreaseIndent ( ( ) => Info ( string . Format ( Strings . LogRegionEnd , title ) ) ) ;
7069 }
@@ -79,7 +78,7 @@ public IndentManager.IndentScope InfoRegion(string messageId, params object[] pa
7978 /// Values of parameters in <paramref name="messageId"/> (resource string or message itself).
8079 /// </param>
8180 /// <param name="exception">Exception, which must be written.</param>
82- public virtual void Debug ( string messageId , object [ ] parameters = null , Exception exception = null ) =>
81+ public virtual void Debug ( string messageId , ReadOnlySpan < object > parameters = default , Exception exception = null ) =>
8382 Write ( LogLevel . Debug , messageId , parameters , exception ) ;
8483
8584 /// <summary>
@@ -91,7 +90,7 @@ public virtual void Debug(string messageId, object[] parameters = null, Exceptio
9190 /// Values of parameters in <paramref name="messageId"/> (resource string or message itself).
9291 /// </param>
9392 /// <param name="exception">Exception, which must be written.</param>
94- public virtual void Info ( string messageId , object [ ] parameters = null , Exception exception = null ) =>
93+ public virtual void Info ( string messageId , ReadOnlySpan < object > parameters = default , Exception exception = null ) =>
9594 Write ( LogLevel . Info , messageId , parameters , exception ) ;
9695
9796 /// <summary>
@@ -104,7 +103,7 @@ public virtual void Info(string messageId, object[] parameters = null, Exception
104103 /// Values of parameters in <paramref name="messageId"/> (resource string or message itself).
105104 /// </param>
106105 /// <param name="exception">Exception, which must be written.</param>
107- public virtual void Warning ( string messageId , object [ ] parameters = null , Exception exception = null ) =>
106+ public virtual void Warning ( string messageId , ReadOnlySpan < object > parameters = default , Exception exception = null ) =>
108107 Write ( LogLevel . Warning , messageId , parameters , exception ) ;
109108
110109 /// <summary>
@@ -117,7 +116,7 @@ public virtual void Warning(string messageId, object[] parameters = null, Except
117116 /// Values of parameters in <paramref name="messageId"/> (resource string or message itself).
118117 /// </param>
119118 /// <param name="exception">Exception, which must be written.</param>
120- public virtual void Error ( string messageId , object [ ] parameters = null , Exception exception = null ) =>
119+ public virtual void Error ( string messageId , ReadOnlySpan < object > parameters = default , Exception exception = null ) =>
121120 Write ( LogLevel . Error , messageId , parameters , exception ) ;
122121
123122 /// <summary>
@@ -130,10 +129,10 @@ public virtual void Error(string messageId, object[] parameters = null, Exceptio
130129 /// Values of parameters in <paramref name="messageId"/> (resource string or message itself).
131130 /// </param>
132131 /// <param name="exception">Exception, which must be written.</param>
133- public virtual void FatalError ( string messageId , object [ ] parameters = null , Exception exception = null ) =>
132+ public virtual void FatalError ( string messageId , ReadOnlySpan < object > parameters = default , Exception exception = null ) =>
134133 Write ( LogLevel . FatalError , messageId , parameters , exception ) ;
135134
136- private void Write ( LogLevel logLevel , string messageId , object [ ] parameters , Exception exception )
135+ private void Write ( LogLevel logLevel , string messageId , ReadOnlySpan < object > parameters , Exception exception )
137136 {
138137 var message = string . IsNullOrEmpty ( messageId )
139138 ? null
0 commit comments