cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • DownloadSemiconductor Toolkit: Tools to create wafer maps, add wafer geometry to graphics, explore die defects & compare wafers.
  • Discovery Summit 2026: Early User Edition - September 23-24.Register. It's free.
  • See how to design an experiment, explore factor-response relationships, assess tradeoffs, and ID best settings. Register for Sep. 11 Mastering JMP.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
uday_guntupalli
Level VIII

Is there a way to build a custom log file in JSL ?

All, 
    I am building an application and would like to enable the users to be able to preview a log file that is custom built along with the script. I am of the opinion that this method, will help both me and the users in the future with troubleshooting. 

 

   I think, one way to write it is by building a list and writing the list out as a text file. But I am open to suggestions and wondering if there is a better, cleaner and more efficient way to do this. 

 

 

Best
Uday
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Is there a way to build a custom log file in JSL ?

I would just use the Save Text File function to append to a rolling log file. Se example below.

// 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" );

Here's the resulting log file:

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
Justin

View solution in original post

2 REPLIES 2

Re: Is there a way to build a custom log file in JSL ?

I would just use the Save Text File function to append to a rolling log file. Se example below.

// 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" );

Here's the resulting log file:

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
Justin
ih
Super User (Alumni) ih
Super User (Alumni)

Re: Is there a way to build a custom log file in JSL ?

I do something similar, here is my strategy for most projects:

  1. All scripts have the same log format, this means it is easy to aggregate them.
  2. For some add-ins logs are automatically uploaded to a central location. JMP 14 has a great method to aggregate all of these.
  3. I use a csv format that also stores other info, like:
    1. Script/Add-In Name and Version
    2. OS/JMP version
    3. Function name
  4. For add-ins, I load the 'writeToLog' function to a namespace for that add-in.  At the top of each script I define that namespace, so in any file within that add-in I can write log messages using ns:log("message", function="foo")

Recommended Articles