Skip to content

Commit a44f048

Browse files
committed
Switch usages of IInternalLogger to IInternalLogger2.
1 parent 32adfd1 commit a44f048

File tree

253 files changed

+1458
-1214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

253 files changed

+1458
-1214
lines changed

src/NHibernate/AdoNet/AbstractBatcher.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace NHibernate.AdoNet
2020
/// </summary>
2121
public abstract partial class AbstractBatcher : IBatcher
2222
{
23-
protected static readonly IInternalLogger Log = LoggerProvider.LoggerFor(typeof(AbstractBatcher));
23+
protected static readonly IInternalLogger2 Log = LoggerProvider.LoggerFor(typeof(AbstractBatcher));
2424

2525
private static int _openCommandCount;
2626
private static int _openReaderCount;
@@ -75,7 +75,7 @@ public DbCommand Generate(CommandType type, SqlString sqlString, SqlType[] param
7575
LogOpenPreparedCommand();
7676
if (Log.IsDebugEnabled)
7777
{
78-
Log.Debug("Building an DbCommand object for the SqlString: " + sql);
78+
Log.Debug("Building an DbCommand object for the SqlString: {0}", sql);
7979
}
8080
_commandsToClose.Add(cmd);
8181
return cmd;
@@ -124,7 +124,7 @@ public virtual DbCommand PrepareBatchCommand(CommandType type, SqlString sql, Sq
124124
{
125125
if (Log.IsDebugEnabled)
126126
{
127-
Log.Debug("reusing command " + _batchCommand.CommandText);
127+
Log.Debug("reusing command {0}", _batchCommand.CommandText);
128128
}
129129
}
130130
else
@@ -199,13 +199,13 @@ public int ExecuteNonQuery(DbCommand cmd)
199199
catch (Exception e)
200200
{
201201
e.Data["actual-sql-query"] = cmd.CommandText;
202-
Log.Error("Could not execute command: " + cmd.CommandText, e);
202+
Log.Error(e, "Could not execute command: {0}", cmd.CommandText);
203203
throw;
204204
}
205205
finally
206206
{
207207
if (Log.IsDebugEnabled && duration != null)
208-
Log.DebugFormat("ExecuteNonQuery took {0} ms", duration.ElapsedMilliseconds);
208+
Log.Debug("ExecuteNonQuery took {0} ms", duration.ElapsedMilliseconds);
209209
}
210210
}
211211

@@ -225,14 +225,14 @@ public virtual DbDataReader ExecuteReader(DbCommand cmd)
225225
catch (Exception e)
226226
{
227227
e.Data["actual-sql-query"] = cmd.CommandText;
228-
Log.Error("Could not execute query: " + cmd.CommandText, e);
228+
Log.Error(e, "Could not execute query: {0}", cmd.CommandText);
229229
throw;
230230
}
231231
finally
232232
{
233233
if (Log.IsDebugEnabled && duration != null && reader != null)
234234
{
235-
Log.DebugFormat("ExecuteReader took {0} ms", duration.ElapsedMilliseconds);
235+
Log.Debug("ExecuteReader took {0} ms", duration.ElapsedMilliseconds);
236236
_readersDuration[reader] = duration;
237237
}
238238
}
@@ -278,7 +278,7 @@ public virtual void CloseCommands()
278278
}
279279
catch (Exception e)
280280
{
281-
Log.Warn("Could not close DbDataReader", e);
281+
Log.Warn(e, "Could not close DbDataReader");
282282
}
283283
}
284284

@@ -291,7 +291,7 @@ public virtual void CloseCommands()
291291
catch (Exception e)
292292
{
293293
// no big deal
294-
Log.Warn("Could not close ADO.NET Command", e);
294+
Log.Warn(e, "Could not close ADO.NET Command");
295295
}
296296
}
297297
_commandsToClose.Clear();
@@ -312,7 +312,7 @@ private void CloseCommand(DbCommand cmd)
312312
}
313313
catch (Exception e)
314314
{
315-
Log.Warn("exception clearing maxRows/queryTimeout", e);
315+
Log.Warn(e, "exception clearing maxRows/queryTimeout");
316316
return; // NOTE: early exit!
317317
}
318318
finally
@@ -368,7 +368,7 @@ public void CloseReader(DbDataReader reader)
368368
catch (Exception e)
369369
{
370370
// NH2205 - prevent exceptions when closing the reader from hiding any original exception
371-
Log.Warn("exception closing reader", e);
371+
Log.Warn(e, "exception closing reader");
372372
}
373373

374374
LogCloseReader();
@@ -390,7 +390,7 @@ private static void LogDuration(Stopwatch duration)
390390
{
391391
if (!Log.IsDebugEnabled || duration == null) return;
392392

393-
Log.DebugFormat("DataReader was closed after {0} ms", duration.ElapsedMilliseconds);
393+
Log.Debug("DataReader was closed after {0} ms", duration.ElapsedMilliseconds);
394394
}
395395

396396
public void ExecuteBatch()
@@ -420,7 +420,7 @@ protected void ExecuteBatchWithTiming(DbCommand ps)
420420
var countBeforeExecutingBatch = CountOfStatementsInCurrentBatch;
421421
DoExecuteBatch(ps);
422422
if (Log.IsDebugEnabled && duration != null)
423-
Log.DebugFormat("ExecuteBatch for {0} statements took {1} ms",
423+
Log.Debug("ExecuteBatch for {0} statements took {1} ms",
424424
countBeforeExecutingBatch,
425425
duration.ElapsedMilliseconds);
426426
}
@@ -481,7 +481,7 @@ private void LogOpenPreparedCommand()
481481
if (Log.IsDebugEnabled)
482482
{
483483
int currentOpenCommandCount = Interlocked.Increment(ref _openCommandCount);
484-
Log.Debug("Opened new DbCommand, open DbCommands: " + currentOpenCommandCount);
484+
Log.Debug("Opened new DbCommand, open DbCommands: {0}", currentOpenCommandCount);
485485
}
486486

487487
if (_factory.Statistics.IsStatisticsEnabled)
@@ -495,7 +495,7 @@ private void LogClosePreparedCommand()
495495
if (Log.IsDebugEnabled)
496496
{
497497
int currentOpenCommandCount = Interlocked.Decrement(ref _openCommandCount);
498-
Log.Debug("Closed DbCommand, open DbCommands: " + currentOpenCommandCount);
498+
Log.Debug("Closed DbCommand, open DbCommands: {0}", currentOpenCommandCount);
499499
}
500500

501501
if (_factory.Statistics.IsStatisticsEnabled)
@@ -509,7 +509,7 @@ private static void LogOpenReader()
509509
if (Log.IsDebugEnabled)
510510
{
511511
int currentOpenReaderCount = Interlocked.Increment(ref _openReaderCount);
512-
Log.Debug("Opened DbDataReader, open DbDataReaders: " + currentOpenReaderCount);
512+
Log.Debug("Opened DbDataReader, open DbDataReaders: {0}", currentOpenReaderCount);
513513
}
514514
}
515515

@@ -518,7 +518,7 @@ private static void LogCloseReader()
518518
if (Log.IsDebugEnabled)
519519
{
520520
int currentOpenReaderCount = Interlocked.Decrement(ref _openReaderCount);
521-
Log.Debug("Closed DbDataReader, open DbDataReaders :" + currentOpenReaderCount);
521+
Log.Debug("Closed DbDataReader, open DbDataReaders :{0}", currentOpenReaderCount);
522522
}
523523
}
524524

@@ -623,4 +623,4 @@ protected SqlString GetSQL(SqlString sql)
623623
return sql;
624624
}
625625
}
626-
}
626+
}

src/NHibernate/AdoNet/ConnectionManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace NHibernate.AdoNet
1919
[Serializable]
2020
public partial class ConnectionManager : ISerializable, IDeserializationCallback
2121
{
22-
private static readonly IInternalLogger _log = LoggerProvider.LoggerFor(typeof(ConnectionManager));
22+
private static readonly IInternalLogger2 _log = LoggerProvider.LoggerFor(typeof(ConnectionManager));
2323

2424
[NonSerialized]
2525
private DbConnection _connection;

src/NHibernate/AdoNet/MySqlClientBatchingBatcher.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public override void AddToBatch(IExpectation expectation)
5757
}
5858
if (Log.IsDebugEnabled)
5959
{
60-
Log.Debug("Adding to batch:" + lineWithParameters);
60+
Log.Debug("Adding to batch:{0}", lineWithParameters);
6161
}
6262
currentBatch.Append(batchUpdate);
6363

@@ -71,7 +71,7 @@ protected override void DoExecuteBatch(DbCommand ps)
7171
{
7272
try
7373
{
74-
Log.DebugFormat("Executing batch");
74+
Log.Debug("Executing batch");
7575
CheckReaders();
7676
if (Factory.Settings.SqlStatementLogger.IsDebugEnabled)
7777
{
@@ -125,7 +125,7 @@ public override void CloseCommands()
125125
{
126126
// Prevent exceptions when clearing the batch from hiding any original exception
127127
// (We do not know here if this batch closing occurs after a failure or not.)
128-
Log.Warn("Exception clearing batch", e);
128+
Log.Warn(e, "Exception clearing batch");
129129
}
130130
}
131131

@@ -140,8 +140,8 @@ protected override void Dispose(bool isDisposing)
140140
}
141141
catch (Exception e)
142142
{
143-
Log.Warn("Exception closing batcher", e);
143+
Log.Warn(e, "Exception closing batcher");
144144
}
145145
}
146146
}
147-
}
147+
}

src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public override void AddToBatch(IExpectation expectation)
5050
}
5151
if (Log.IsDebugEnabled)
5252
{
53-
Log.Debug("Adding to batch:" + lineWithParameters);
53+
Log.Debug("Adding to batch:{0}", lineWithParameters);
5454
}
5555

5656
if (_currentBatch == null)
@@ -167,4 +167,4 @@ public override int BatchSize
167167
set { _batchSize = value; }
168168
}
169169
}
170-
}
170+
}

src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public override void AddToBatch(IExpectation expectation)
5959
}
6060
if (Log.IsDebugEnabled)
6161
{
62-
Log.Debug("Adding to batch:" + lineWithParameters);
62+
Log.Debug("Adding to batch:{0}", lineWithParameters);
6363
}
6464
_currentBatch.Append((System.Data.SqlClient.SqlCommand)batchUpdate);
6565

@@ -73,7 +73,7 @@ protected override void DoExecuteBatch(DbCommand ps)
7373
{
7474
try
7575
{
76-
Log.DebugFormat("Executing batch");
76+
Log.Debug("Executing batch");
7777
CheckReaders();
7878
Prepare(_currentBatch.BatchCommand);
7979
if (Factory.Settings.SqlStatementLogger.IsDebugEnabled)
@@ -111,7 +111,7 @@ private SqlClientSqlCommandSet CreateConfiguredBatch()
111111
{
112112
if (Log.IsWarnEnabled)
113113
{
114-
Log.Warn(e.ToString());
114+
Log.Warn(e, e.ToString());
115115
}
116116
}
117117
}
@@ -143,7 +143,7 @@ public override void CloseCommands()
143143
}
144144
catch (Exception e)
145145
{
146-
Log.Warn("Exception clearing batch", e);
146+
Log.Warn(e, "Exception clearing batch");
147147
}
148148
}
149149

@@ -158,8 +158,8 @@ protected override void Dispose(bool isDisposing)
158158
}
159159
catch (Exception e)
160160
{
161-
Log.Warn("Exception closing batcher", e);
161+
Log.Warn(e, "Exception closing batcher");
162162
}
163163
}
164164
}
165-
}
165+
}

src/NHibernate/AdoNet/Util/SqlStatementLogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace NHibernate.AdoNet.Util
88
/// <summary> Centralize logging handling for SQL statements. </summary>
99
public class SqlStatementLogger
1010
{
11-
private static readonly IInternalLogger Logger = LoggerProvider.LoggerFor("NHibernate.SQL");
11+
private static readonly IInternalLogger2 Logger = LoggerProvider.LoggerFor("NHibernate.SQL");
1212

1313
/// <summary> Constructs a new SqlStatementLogger instance.</summary>
1414
public SqlStatementLogger() : this(false, false)

src/NHibernate/AssertionFailure.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public AssertionFailure() : base(String.Empty)
2626
/// <param name="message">The message that describes the error. </param>
2727
public AssertionFailure(string message) : base(message)
2828
{
29-
LoggerProvider.LoggerFor(typeof(AssertionFailure)).Error(DefaultMessage, this);
29+
LoggerProvider.LoggerFor(typeof(AssertionFailure)).Error(this, DefaultMessage);
3030
}
3131

3232
/// <summary>
@@ -40,7 +40,7 @@ public AssertionFailure(string message) : base(message)
4040
/// </param>
4141
public AssertionFailure(string message, Exception innerException) : base(message, innerException)
4242
{
43-
LoggerProvider.LoggerFor(typeof(AssertionFailure)).Error(DefaultMessage, innerException);
43+
LoggerProvider.LoggerFor(typeof(AssertionFailure)).Error(innerException, DefaultMessage);
4444
}
4545

4646
/// <summary>

src/NHibernate/Async/AdoNet/AbstractBatcher.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public virtual async Task<DbCommand> PrepareBatchCommandAsync(CommandType type,
7474
{
7575
if (Log.IsDebugEnabled)
7676
{
77-
Log.Debug("reusing command " + _batchCommand.CommandText);
77+
Log.Debug("reusing command {0}", _batchCommand.CommandText);
7878
}
7979
}
8080
else
@@ -126,13 +126,13 @@ public async Task<int> ExecuteNonQueryAsync(DbCommand cmd, CancellationToken can
126126
catch (Exception e)
127127
{
128128
e.Data["actual-sql-query"] = cmd.CommandText;
129-
Log.Error("Could not execute command: " + cmd.CommandText, e);
129+
Log.Error(e, "Could not execute command: {0}", cmd.CommandText);
130130
throw;
131131
}
132132
finally
133133
{
134134
if (Log.IsDebugEnabled && duration != null)
135-
Log.DebugFormat("ExecuteNonQuery took {0} ms", duration.ElapsedMilliseconds);
135+
Log.Debug("ExecuteNonQuery took {0} ms", duration.ElapsedMilliseconds);
136136
}
137137
}
138138

@@ -153,14 +153,14 @@ public virtual async Task<DbDataReader> ExecuteReaderAsync(DbCommand cmd, Cancel
153153
catch (Exception e)
154154
{
155155
e.Data["actual-sql-query"] = cmd.CommandText;
156-
Log.Error("Could not execute query: " + cmd.CommandText, e);
156+
Log.Error(e, "Could not execute query: {0}", cmd.CommandText);
157157
throw;
158158
}
159159
finally
160160
{
161161
if (Log.IsDebugEnabled && duration != null && reader != null)
162162
{
163-
Log.DebugFormat("ExecuteReader took {0} ms", duration.ElapsedMilliseconds);
163+
Log.Debug("ExecuteReader took {0} ms", duration.ElapsedMilliseconds);
164164
_readersDuration[reader] = duration;
165165
}
166166
}
@@ -224,7 +224,7 @@ protected async Task ExecuteBatchWithTimingAsync(DbCommand ps, CancellationToken
224224
var countBeforeExecutingBatch = CountOfStatementsInCurrentBatch;
225225
await (DoExecuteBatchAsync(ps, cancellationToken)).ConfigureAwait(false);
226226
if (Log.IsDebugEnabled && duration != null)
227-
Log.DebugFormat("ExecuteBatch for {0} statements took {1} ms",
227+
Log.Debug("ExecuteBatch for {0} statements took {1} ms",
228228
countBeforeExecutingBatch,
229229
duration.ElapsedMilliseconds);
230230
}
@@ -242,4 +242,4 @@ protected async Task ExecuteBatchWithTimingAsync(DbCommand ps, CancellationToken
242242
/// </remarks>
243243
public abstract Task AddToBatchAsync(IExpectation expectation, CancellationToken cancellationToken);
244244
}
245-
}
245+
}

src/NHibernate/Async/AdoNet/MySqlClientBatchingBatcher.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public override async Task AddToBatchAsync(IExpectation expectation, Cancellatio
4242
}
4343
if (Log.IsDebugEnabled)
4444
{
45-
Log.Debug("Adding to batch:" + lineWithParameters);
45+
Log.Debug("Adding to batch:{0}", lineWithParameters);
4646
}
4747
currentBatch.Append(batchUpdate);
4848

@@ -57,7 +57,7 @@ protected override async Task DoExecuteBatchAsync(DbCommand ps, CancellationToke
5757
cancellationToken.ThrowIfCancellationRequested();
5858
try
5959
{
60-
Log.DebugFormat("Executing batch");
60+
Log.Debug("Executing batch");
6161
await (CheckReadersAsync(cancellationToken)).ConfigureAwait(false);
6262
if (Factory.Settings.SqlStatementLogger.IsDebugEnabled)
6363
{
@@ -82,4 +82,4 @@ protected override async Task DoExecuteBatchAsync(DbCommand ps, CancellationToke
8282
}
8383
}
8484
}
85-
}
85+
}

src/NHibernate/Async/AdoNet/OracleDataClientBatchingBatcher.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public override Task AddToBatchAsync(IExpectation expectation, CancellationToken
4646
}
4747
if (Log.IsDebugEnabled)
4848
{
49-
Log.Debug("Adding to batch:" + lineWithParameters);
49+
Log.Debug("Adding to batch:{0}", lineWithParameters);
5050
}
5151

5252
if (_currentBatch == null)
@@ -151,4 +151,4 @@ protected override async Task DoExecuteBatchAsync(DbCommand ps, CancellationToke
151151
}
152152
}
153153
}
154-
}
154+
}

0 commit comments

Comments
 (0)