Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 1ddcaf8

Browse files
committed
Change [Conditional] logging in favor of Log.IsDebugEnabled
1 parent 99bbd31 commit 1ddcaf8

File tree

5 files changed

+14
-29
lines changed

5 files changed

+14
-29
lines changed

src/ServiceStack.OrmLite/OrmLiteDialectProviderBase.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,6 @@ protected OrmLiteDialectProviderBase()
3636
StringSerializer = new JsvStringSerializer();
3737
}
3838

39-
[Conditional("DEBUG")]
40-
private static void LogDebug(string fmt, params object[] args)
41-
{
42-
if (args.Length > 0)
43-
Log.DebugFormat(fmt, args);
44-
else
45-
Log.Debug(fmt);
46-
}
47-
4839
#region ADO.NET supported types
4940
/* ADO.NET UNDERSTOOD DATA TYPES:
5041
COUNTER DbType.Int64

src/ServiceStack.OrmLite/OrmLiteReadExtensions.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@
1313
using System.Collections;
1414
using System.Collections.Generic;
1515
using System.Data;
16-
using System.Diagnostics;
1716
using System.Globalization;
1817
using System.Reflection;
1918
using System.Text;
2019
using ServiceStack.Logging;
21-
using ServiceStack.Text;
2220
using System.Linq;
2321

2422
namespace ServiceStack.OrmLite
@@ -35,26 +33,26 @@ public static class OrmLiteReadExtensions
3533
private static readonly ILog Log = LogManager.GetLogger(typeof(OrmLiteReadExtensions));
3634
public const string UseDbConnectionExtensions = "Use IDbConnection Extensions instead";
3735

38-
[Conditional("DEBUG")]
39-
private static void LogDebug(string fmt, params object[] args)
36+
private static void LogDebug(string fmt)
4037
{
41-
if (args.Length > 0)
42-
Log.DebugFormat(fmt, args);
43-
else
44-
Log.Debug(fmt);
38+
Log.Debug(fmt);
4539
}
4640

4741
internal static IDataReader ExecReader(this IDbCommand dbCmd, string sql)
4842
{
49-
LogDebug(sql);
43+
if (Log.IsDebugEnabled)
44+
LogDebug(sql);
45+
5046
dbCmd.CommandTimeout = OrmLiteConfig.CommandTimeout;
5147
dbCmd.CommandText = sql;
5248
return dbCmd.ExecuteReader();
5349
}
5450

5551
internal static IDataReader ExecReader(this IDbCommand dbCmd, string sql, IEnumerable<IDataParameter> parameters)
5652
{
57-
LogDebug(sql);
53+
if (Log.IsDebugEnabled)
54+
LogDebug(sql);
55+
5856
dbCmd.CommandTimeout = OrmLiteConfig.CommandTimeout;
5957
dbCmd.CommandText = sql;
6058
dbCmd.Parameters.Clear();

src/ServiceStack.OrmLite/OrmLiteWriteExtensions.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
using System.Collections;
1414
using System.Collections.Generic;
1515
using System.Data;
16-
using System.Diagnostics;
1716
using System.Linq;
1817
using System.Text.RegularExpressions;
1918
using ServiceStack.Logging;
@@ -23,15 +22,10 @@ namespace ServiceStack.OrmLite
2322
public static class OrmLiteWriteExtensions
2423
{
2524
private static readonly ILog Log = LogManager.GetLogger(typeof(OrmLiteWriteExtensions));
26-
private const string UseDbConnectionExtensions = "Use IDbConnection Extensions instead";
2725

28-
[Conditional("DEBUG")]
29-
private static void LogDebug(string fmt, params object[] args)
26+
private static void LogDebug(string fmt)
3027
{
31-
if (args.Length > 0)
32-
Log.DebugFormat(fmt, args);
33-
else
34-
Log.Debug(fmt);
28+
Log.Debug(fmt);
3529
}
3630

3731
internal static void CreateTables(this IDbCommand dbCmd, bool overwrite, params Type[] tableTypes)
@@ -212,7 +206,8 @@ internal static string LastSql(this IDbCommand dbCmd)
212206

213207
internal static int ExecuteSql(this IDbCommand dbCmd, string sql)
214208
{
215-
LogDebug(sql);
209+
if (Log.IsDebugEnabled)
210+
LogDebug(sql);
216211

217212
dbCmd.CommandText = sql;
218213

tests/ServiceStack.OrmLite.Tests/JoinSqlBuilderTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Text.RegularExpressions;
22
using NUnit.Framework;
33
using ServiceStack.DataAnnotations;
4+
using ServiceStack.Logging;
45
using ServiceStack.Text;
56

67
namespace ServiceStack.OrmLite.Tests

tests/ServiceStack.OrmLite.Tests/OrmLiteTestBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ protected void CreateNewDatabase()
6565
[TestFixtureSetUp]
6666
public void TestFixtureSetUp()
6767
{
68-
LogManager.LogFactory = new ConsoleLogFactory();
68+
LogManager.LogFactory = new ConsoleLogFactory(debugEnabled:false);
6969

7070
switch (Dialect)
7171
{

0 commit comments

Comments
 (0)