Skip to content

Commit ec7b882

Browse files
Merge pull request robertohuertasm#22 from pokehanai/feature/unity_trace
Added `TraceEvent` to receive `Trace` output.
2 parents ac37470 + a4d681b commit ec7b882

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

SQLite4Unity3d/SQLite4Unity3d/SQLite.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,22 @@ public partial class SQLiteConnection : IDisposable
142142

143143
public bool TimeExecution { get; set; }
144144

145+
#region debug tracing
146+
145147
public bool Trace { get; set; }
146148

149+
public delegate void TraceHandler (string message);
150+
public event TraceHandler TraceEvent;
151+
152+
internal void InvokeTrace (string message)
153+
{
154+
if (TraceEvent != null) {
155+
TraceEvent(message);
156+
}
157+
}
158+
159+
#endregion
160+
147161
public bool StoreDateTimeAsTicks { get; private set; }
148162

149163
/// <summary>
@@ -1982,7 +1996,7 @@ internal SQLiteCommand (SQLiteConnection conn)
19821996
public int ExecuteNonQuery ()
19831997
{
19841998
if (_conn.Trace) {
1985-
Debug.WriteLine ("Executing: " + this);
1999+
_conn.InvokeTrace ("Executing: " + this);
19862000
}
19872001

19882002
var r = SQLite3.Result.OK;
@@ -2040,7 +2054,7 @@ protected virtual void OnInstanceCreated (object obj)
20402054
public IEnumerable<T> ExecuteDeferredQuery<T> (TableMapping map)
20412055
{
20422056
if (_conn.Trace) {
2043-
Debug.WriteLine ("Executing Query: " + this);
2057+
_conn.InvokeTrace ("Executing Query: " + this);
20442058
}
20452059

20462060
var stmt = Prepare ();
@@ -2075,7 +2089,7 @@ public IEnumerable<T> ExecuteDeferredQuery<T> (TableMapping map)
20752089
public T ExecuteScalar<T> ()
20762090
{
20772091
if (_conn.Trace) {
2078-
Debug.WriteLine ("Executing Query: " + this);
2092+
_conn.InvokeTrace ("Executing Query: " + this);
20792093
}
20802094

20812095
T val = default(T);
@@ -2291,7 +2305,7 @@ internal PreparedSqlLiteInsertCommand (SQLiteConnection conn)
22912305
public int ExecuteNonQuery (object[] source)
22922306
{
22932307
if (Connection.Trace) {
2294-
Debug.WriteLine ("Executing: " + CommandText);
2308+
Connection.InvokeTrace ("Executing: " + CommandText);
22952309
}
22962310

22972311
var r = SQLite3.Result.OK;

0 commit comments

Comments
 (0)