banshee r3651 - in trunk/banshee: . src/Core/Banshee.Core/Banshee.Base src/Core/Banshee.Services/Banshee.Database src/Libraries/Hyena/Hyena.Data.Sqlite
- From: scottp svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3651 - in trunk/banshee: . src/Core/Banshee.Core/Banshee.Base src/Core/Banshee.Services/Banshee.Database src/Libraries/Hyena/Hyena.Data.Sqlite
- Date: Thu, 3 Apr 2008 03:05:52 +0100 (BST)
Author: scottp
Date: Thu Apr 3 03:05:52 2008
New Revision: 3651
URL: http://svn.gnome.org/viewvc/banshee?rev=3651&view=rev
Log:
You can now pass --debug-sql to get a full log of all SQL commands
executed.
* src/Core/Banshee.Services/Banshee.Database/BansheeDbConnection.cs:
Listen to Executing event and log the command text if we're
debugging the SQL.
* src/Core/Banshee.Core/Banshee.Base/ApplicationContext.cs: We're also
debugging if --debug-sql was passed.
* src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs: Raise
HyenaSqliteConnection.Executing event.
* src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteConnection.cs: Added
Executing event.
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.Core/Banshee.Base/ApplicationContext.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbConnection.cs
trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs
trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteConnection.cs
Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.Base/ApplicationContext.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.Base/ApplicationContext.cs (original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Base/ApplicationContext.cs Thu Apr 3 03:05:52 2008
@@ -52,6 +52,7 @@
get {
if (debugging == null) {
debugging = CommandLine.Contains ("debug");
+ debugging |= CommandLine.Contains ("debug-sql");
debugging |= EnvironmentIsSet ("BANSHEE_DEBUG");
}
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbConnection.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbConnection.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbConnection.cs Thu Apr 3 03:05:52 2008
@@ -55,6 +55,12 @@
Execute ("PRAGMA case_sensitive_like=ON");
migrator = new BansheeDbFormatMigrator (this);
+
+ if (Banshee.Base.ApplicationContext.CommandLine.Contains ("debug-sql")) {
+ this.Executing += delegate (object sender, ExecutingEventArgs args) {
+ Log.Debug (String.Format ("Executing: {0}", args.Command.CommandText));
+ };
+ }
}
void IInitializeService.Initialize ()
Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs (original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs Thu Apr 3 03:05:52 2008
@@ -77,7 +77,7 @@
ApplyValues (param_values);
}
- internal void Execute (SqliteConnection connection)
+ internal void Execute (HyenaSqliteConnection hconnection, SqliteConnection connection)
{
if (finished) {
throw new Exception ("Command is already set to finished; result needs to be claimed before command can be rerun");
@@ -89,6 +89,7 @@
SqliteCommand sql_command = new SqliteCommand (CurrentSqlText);
sql_command.Connection = connection;
//Log.DebugFormat ("Executing {0}", sql_command.CommandText);
+ hconnection.OnExecuting (new ExecutingEventArgs (sql_command));
try {
switch (command_type) {
Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteConnection.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteConnection.cs (original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteConnection.cs Thu Apr 3 03:05:52 2008
@@ -39,6 +39,15 @@
namespace Hyena.Data.Sqlite
{
+ public class ExecutingEventArgs : EventArgs
+ {
+ public readonly SqliteCommand Command;
+ public ExecutingEventArgs (SqliteCommand command)
+ {
+ Command = command;
+ }
+ }
+
public enum HyenaCommandType {
Reader,
Scalar,
@@ -64,6 +73,8 @@
get { return result_ready_signal; }
}
+ public event EventHandler<ExecutingEventArgs> Executing;
+
public HyenaSqliteConnection(string dbpath)
{
this.dbpath = dbpath;
@@ -315,8 +326,8 @@
lock (command_queue) {
command = command_queue.Dequeue ();
}
-
- command.Execute (connection);
+
+ command.Execute (this, connection);
lock (command_queue) {
results_ready++;
@@ -330,6 +341,14 @@
// Finish
connection.Close ();
}
+
+ internal void OnExecuting (ExecutingEventArgs args)
+ {
+ EventHandler<ExecutingEventArgs> handler = Executing;
+ if (handler != null) {
+ handler (this, args);
+ }
+ }
#endregion
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]