<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Is there a way to build a custom log file in JSL ? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-build-a-custom-log-file-in-JSL/m-p/50544#M28734</link>
    <description>&lt;P&gt;I do something similar, here is my strategy for most projects:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;All scripts have the same log format, this means it is easy to aggregate them.&lt;/LI&gt;&lt;LI&gt;For some add-ins logs are automatically uploaded to a central location. JMP 14 has a great method to aggregate all of these.&lt;/LI&gt;&lt;LI&gt;I use a csv format that also stores other info, like:&lt;OL&gt;&lt;LI&gt;Script/Add-In Name and Version&lt;/LI&gt;&lt;LI&gt;OS/JMP version&lt;/LI&gt;&lt;LI&gt;Function name&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;For add-ins, I load the 'writeToLog' function to a namespace for that add-in.&amp;nbsp; 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")&lt;/LI&gt;&lt;/OL&gt;</description>
    <pubDate>Wed, 31 Jan 2018 21:10:48 GMT</pubDate>
    <dc:creator>ih</dc:creator>
    <dc:date>2018-01-31T21:10:48Z</dc:date>
    <item>
      <title>Is there a way to build a custom log file in JSL ?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-build-a-custom-log-file-in-JSL/m-p/50518#M28718</link>
      <description>&lt;P&gt;All,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; 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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 17:31:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-build-a-custom-log-file-in-JSL/m-p/50518#M28718</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2018-01-31T17:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to build a custom log file in JSL ?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-build-a-custom-log-file-in-JSL/m-p/50532#M28725</link>
      <description>&lt;P&gt;I would&amp;nbsp;&lt;U&gt;&lt;/U&gt;just use the Save Text File function to append to a rolling log file. Se example below.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// 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" );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here's the resulting log file:&lt;/P&gt;
&lt;PRE&gt;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&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Jan 2018 18:59:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-build-a-custom-log-file-in-JSL/m-p/50532#M28725</guid>
      <dc:creator>Justin_Chilton</dc:creator>
      <dc:date>2018-01-31T18:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to build a custom log file in JSL ?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-build-a-custom-log-file-in-JSL/m-p/50544#M28734</link>
      <description>&lt;P&gt;I do something similar, here is my strategy for most projects:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;All scripts have the same log format, this means it is easy to aggregate them.&lt;/LI&gt;&lt;LI&gt;For some add-ins logs are automatically uploaded to a central location. JMP 14 has a great method to aggregate all of these.&lt;/LI&gt;&lt;LI&gt;I use a csv format that also stores other info, like:&lt;OL&gt;&lt;LI&gt;Script/Add-In Name and Version&lt;/LI&gt;&lt;LI&gt;OS/JMP version&lt;/LI&gt;&lt;LI&gt;Function name&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;For add-ins, I load the 'writeToLog' function to a namespace for that add-in.&amp;nbsp; 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")&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Wed, 31 Jan 2018 21:10:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-build-a-custom-log-file-in-JSL/m-p/50544#M28734</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2018-01-31T21:10:48Z</dc:date>
    </item>
  </channel>
</rss>

