全て、
アプリケーションを構築しており、スクリプトとともにカスタム構築されたログ ファイルをユーザーがプレビューできるようにしたいと考えています。 この方法は、将来私とユーザーの両方のトラブルシューティングに役立つと私は考えています。
リストを作成し、そのリストをテキスト ファイルとして書き出すのも 1 つの方法だと思います。 しかし、私は提案を歓迎し、これを行うためのより良く、よりクリーンで、より効率的な方法はないかと考えています。
私も同様のことをしています。ほとんどのプロジェクトに対する私の戦略は次のとおりです。
- すべてのスクリプトのログ形式は同じなので、簡単に集約できます。
- 一部のアドインのログは、中央の場所に自動的にアップロードされます。 JMP 14 には、これらすべてを集約する優れた方法があります。
- 私は、次のような他の情報も保存する CSV 形式を使用します。
- スクリプト/アドインの名前とバージョン
- OS/JMPのバージョン
- 関数名
- アドインの場合は、「writeToLog」関数をそのアドインの名前空間に読み込みます。各スクリプトの先頭で名前空間を定義するので、そのアドイン内の任意のファイルに ns:log("message", function="foo") を使用してログ メッセージを書き込むことができます。
私は...するだろうテキスト ファイルの保存機能を使用して、ローリング ログ ファイルに追加するだけです。 以下の例を参照してください。
// some variables to show
x = 5;
y = 10;
z = 25;
// path to the log
logFilePath = "$TEMP/MyJmpAddin2.log";
// initialize the log in case it doesnt exist
If( !File Exists( logFilePath ), Save Text File( logFilePath, "" ) );
// function to write to the log file (with a new line character at the end)
writeToLog = Function( {str},
Save Text File(
logFilePath,
Format( Today(), "m/d/y h:m:s" ) || " - " || str || "\!N",
Mode( "append" )
)
);
writeToLog( "showing x in JMP log" );
show( x );
writeToLog( "showing y in JMP log" );
show( y );
writeToLog( "showing z in JMP log" );
show( z );
// for demonstration purposes, open the log file as plain text
Open( logFilePath, "plain text" );
結果のログ ファイルは次のとおりです。
01/31/2018 1:56:23 PM - showing x in JMP log
01/31/2018 1:56:23 PM - showing y in JMP log
01/31/2018 1:56:23 PM - showing z in JMP log