Skip to content

Commit

Permalink
SQL PRINT statements come back to the loger - chucknorris/roundhouse#68
Browse files Browse the repository at this point in the history
  • Loading branch information
ferventcoder committed Sep 7, 2012
1 parent 53e029d commit 050b8f0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions product/roundhouse.databases.oracle/OracleDatabase.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Data.OracleClient;
using roundhouse.infrastructure.logging;

namespace roundhouse.databases.oracle
Expand Down Expand Up @@ -86,6 +87,11 @@ public override void set_provider()
provider = "System.Data.OracleClient";
}

protected override void connection_specific_setup(IDbConnection connection)
{
((OracleConnection)connection).InfoMessage += (sender, e) => Log.bound_to(this).log_an_info_event_containing(" [SQL PRINT]: {0}{1}",Environment.NewLine, e.Message);
}

public override void run_database_specific_tasks()
{
Log.bound_to(this).log_an_info_event_containing("Creating a sequence for the '{0}' table.", version_table_name);
Expand Down
7 changes: 7 additions & 0 deletions product/roundhouse.databases.sqlserver/SqlServerDatabase.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Data.SqlClient;

namespace roundhouse.databases.sqlserver
{
using System;
Expand Down Expand Up @@ -79,6 +81,11 @@ private static string build_connection_string(string server_name, string databas
return string.Format("data source={0};initial catalog={1};{2}", server_name, database_name, connection_options);
}

protected override void connection_specific_setup(IDbConnection connection)
{
((SqlConnection)connection).InfoMessage += (sender, e) => Log.bound_to(this).log_an_info_event_containing(" [SQL PRINT]: {0}{1}", Environment.NewLine, e.Message);
}

public override void run_database_specific_tasks()
{
Log.bound_to(this).log_an_info_event_containing(" Creating {0} schema if it doesn't exist.", roundhouse_schema_name);
Expand Down
6 changes: 6 additions & 0 deletions product/roundhouse/databases/AdoNetDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ private AdoNetConnection GetAdoNetConnection(string conn_string)
{
provider_factory = DbProviderFactories.GetFactory(provider);
IDbConnection connection = provider_factory.CreateConnection();
connection_specific_setup(connection);

connection.ConnectionString = conn_string;
return new AdoNetConnection(connection);
}

protected virtual void connection_specific_setup(IDbConnection connection)
{
}

public override void open_admin_connection()
{
Log.bound_to(this).log_a_debug_event_containing("Opening admin connection to '{0}'", admin_connection_string);
Expand Down

0 comments on commit 050b8f0

Please sign in to comment.