Skip to content

Commit

Permalink
Merge pull request DbUp#89 from gfody/master
Browse files Browse the repository at this point in the history
fixes DbUp#88
  • Loading branch information
JakeGinnivan committed Apr 11, 2015
2 parents 8f8dc1f + 325bc0c commit 70d9092
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/DbUp/Builder/StandardExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,19 @@ public static UpgradeEngineBuilder LogScriptOutput(this UpgradeEngineBuilder bui
public static UpgradeEngineBuilder LogToTrace(this UpgradeEngineBuilder builder)
{
return LogTo(builder, new TraceUpgradeLog());
}
}

/// <summary>
/// Logs to SqlContext.Pipe, for use with "context connection=true".
/// </summary>
/// <param name="builder">The builder.</param>
/// <returns>
/// The same builder
/// </returns>
public static UpgradeEngineBuilder LogToSqlContext(this UpgradeEngineBuilder builder)
{
return LogTo(builder, new SqlContextUpgradeLog());
}

/// <summary>
/// Uses a custom journal for recording which scripts were executed.
Expand Down
1 change: 1 addition & 0 deletions src/DbUp/DbUp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<Compile Include="Builder\UpgradeEngineBuilder.cs" />
<Compile Include="DeployChanges.cs" />
<Compile Include="Engine\DelegateDisposable.cs" />
<Compile Include="Engine\Output\SqlContextUpgradeLog.cs" />
<Compile Include="Engine\Transactions\DatabaseConnectionManager.cs" />
<Compile Include="Engine\IScript.cs" />
<Compile Include="Engine\Transactions\SingleTrasactionStrategy.cs" />
Expand Down
22 changes: 22 additions & 0 deletions src/DbUp/Engine/Output/SqlContextUpgradeLog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.SqlServer.Server;

namespace DbUp.Engine.Output
{
internal class SqlContextUpgradeLog : IUpgradeLog
{
public void WriteInformation(string format, params object[] args)
{
SqlContext.Pipe.Send("INFO: " + string.Format(format, args));
}

public void WriteError(string format, params object[] args)
{
SqlContext.Pipe.Send("ERROR: " + string.Format(format, args));
}

public void WriteWarning(string format, params object[] args)
{
SqlContext.Pipe.Send("WARN: " + string.Format(format, args));
}
}
}
2 changes: 1 addition & 1 deletion src/DbUp/Support/SqlServer/SqlScriptExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public virtual void Execute(SqlScript script, IDictionary<string, string> variab
}
}

private virtual void Log(IDataReader reader)
public virtual void Log(IDataReader reader)
{
do
{
Expand Down

0 comments on commit 70d9092

Please sign in to comment.