プロキシー・コードのデバッグのためのログの実装

Functional Tester は、開発したプロキシー・コードをデバッグするときに使用できるログ・インフラストラクチャーを提供します。 FTDebug クラスは、Java™ と .Net 両方のプロキシー開発フレームワークで使用できます。 各プロキシー・クラスごとに FTDebug クラスのオブジェクトをインスタンス化し、通知、警告、またはエラー・メッセージをカテゴリー別にログに記録することができます。
始める前に

以下のサンプル・コードは、Java でプロキシー・コードのロギングを実装する方法を示しています。

import com.rational.test.ft.util.FtDebug;
.
public class MyProxy extends BaseProxy
{
	protected static FtDebug debug = new FtDebug("myproxies");
	.
	void anyMethod()
	{
		debug.trace("Beginging of anyMethod()");
		.
		debug.verbose("I'm doing this!");
		.
		debug.warning("Not critical, good to have it fixed");
		.
		debug.error("I shouldn't have been here!!") ;
		.
		debug.trace("End of anyMethod()");
	}
}

以下のサンプル・コードは、.Net でプロキシー・コードのロギングを実装する方法を示しています。

.
using Rational.Test.Ft.Util;
.
public class MyProxy : BaseProxy
{
	protected static FtDebug debug = new FtDebug("myproxies");
	.
	void anyMethod()
	{
		debug.Trace("Beginging of anyMethod()");
		.
		debug.Verbose("I'm doing this!");
		.
		debug.Warning("Not critical, good to have it fixed");
		.
		debug.Error("I shouldn't have been here!!") ;
		.
		debug.Trace("End of anyMethod()");
	}
}

この例では、FtDebug() メソッドは myproxies ストリングを渡します。 ivory.properties ファイル (C:¥Program Files¥IBM¥SDP70¥FunctionalTester¥bin¥ から入手可能) でこのストリングを使用して、実行中に出されるログ情報のレベルを制御することができます。 以下のサンプル・コードは、ivory.properties ファイルで myproxies ストリングを使用する方法を示しています。

###
### Debugging options
###
# The following propeties are used to control the debugging output generated by the FT
# product.  In production versions this output is minimal, limited primarily to error
# and warning level information.
rational.test.ft.debug.enabled=true
rational.test.ft.debug.clear_on_init=false
rational.test.ft.debug.filename=c:/ivDebug.txt
# filter levels: error,0;warning,1;debug,2;verbose,3
rational.test.ft.debug.filter=default,1;myproxies,3;
この例では、myproxies ストリングの値は 3 に設定されます。 こうして、ivDebug.txt ファイルに書き込まれるデバッグ情報のレベルを制御することができます。

フィードバック