mcode-log
Version:
A stand-alone package of core code for logging and debugging.
2,807 lines (770 loc) • 33.2 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Namespace: mcode</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Namespace: mcode</h1>
<section>
<header>
<h2>mcode</h2>
</header>
<article>
<div class="container-overview">
<div class="description">mcode namespace containing functions and constants.</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line102">line 102</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id=".vt"><span class="type-signature">(static, constant) </span>vt<span class="type-signature"></span></h4>
<div class="description">
Colors constants for changing Console appearance ala DEC's VT52 + VT100 + VT220.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line108">line 108</a>
</li></ul></dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>ANSI Color Escape Sequence
\x1b[***m -- where '***' is a series of command codes separated by semi-colons (;).
Code Effect -- notes
------------------------------------------------------------------------------
0 Reset / Normal -- all attributes off
1 Bold -- increased intensity
2 Faint -- decreased intensity - not widely supported
3 Italic -- not widely supported, sometimes treated as inverse
4 Underline
5 Slow Blink -- less than 150 per minute
6 Rapid Blink -- MS-DOS ANSI.SYS; 150+ per minute; not widely supported
7 Reverse video -- swap foreground and background colors
8 Conceal -- not widely supported.
9 Crossed-out -- characters legible, but marked for deletion. Not widely supported
10 Primary font (default)
11–19 Alternate font -- select alternate font n-10
20 Fraktur -- hardly ever supported
21 Bold off or Double Underline -- bold off not widely supported; double underline hardly ever supported
22 Normal color or intensity -- neither bold nor faint
23 Not italic, not Fraktur
24 Underline roundOff -- not singly or doubly underlined
25 Blink off
27 Inverse off
28 Reveal conceal off
29 Not crossed out
30–37 Set foreground color -- see color table below
38 Set foreground color -- next arguments are 5;<n> or 2;<r>;<g>;<b>, see below
39 Default foreground color -- implementation defined (according to standard)
40–47 Set background color -- see color table below
48 Set background color -- next arguments are 5;<n> or 2;<r>;<g>;<b>, see below
49 Default background color -- implementation defined (according to standard)
51 Framed
52 Encircled
53 Overlined
54 Not framed or encircled
55 Not overlined
60 ideogram underline -- hardly ever supported
61 ideogram double underline -- hardly ever supported
62 ideogram overline -- hardly ever supported
63 ideogram double overline -- hardly ever supported
64 ideogram stress marking hardly ever supported
65 ideogram attributes off reset the effects of all of 60-64
90–97 Set bright foreground color aixterm (not in standard)
100–107 Set bright background color aixterm (not in standard)</code></pre>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id=".exp"><span class="type-signature">(static) </span>exp<span class="signature">(message, source, exception)</span><span class="type-signature"> → {string}</span></h4>
<div class="description">
logs an exception to the Console in a standardized format and a stack dump.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>message</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">pre-formatted message to be logged.</td>
</tr>
<tr>
<td class="name"><code>source</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">where the message orginated.</td>
</tr>
<tr>
<td class="name"><code>exception</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">the underlying exception message that was caught.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line387">line 387</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
"message: {message} - exception: {exception}" for display in UI.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".extractId"><span class="type-signature">(static) </span>extractId<span class="signature">(objectName)</span><span class="type-signature"> → {string}</span></h4>
<div class="description">
Extracts an alpha-numberic ID Field from a string, intended to be a unique portion of a common string.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>objectName</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">typically a file name, but can be any string, to extract an ID Field from.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line1037">line 1037</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
the extracted ID Field.
Rules for extracting the ID Field:
----------------------------------
1. The ID Field is assumed to be the first alpha-numeric field in the string.
2. The ID Field is assumed to be Letters + Numbers, with no spaces or special characters.
3. The ID Field is assumed to be either at the beginning or end of the string, or separated by non-alpha-numeric characters.
4. The ID Field cound have lowercase 'placeholders' for numbers, like 'PxCy' or 'PnCn' for 'P1C2'.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>const str1 = "CG_BRKE01_20231116.L5K";
const str2 = "CG_BRKE03_20231116.L5K";
console.log(extractIdField(str1)); // Expected output: "BRKE01"
console.log(extractIdField(str2)); // Expected output: "BRKE03"
const str1 = "EP_GPT13TZ1_20231115_0800.L5K";
const str2 = "EP_GPT13TZ2_20231113_1600.L5K";
console.log(extractIdField(str1)); // Expected output: "GPT13TZ1"
console.log(extractIdField(str2)); // Expected output: "GPT13TZ2"
const str1 = "SEP_P1C2_GMP_ARL.L5K";
const str2 = "SEP_P3C0_GMP_ARL.L5K";
console.log(extractIdField(str1)); // Expected output: "P1C2"
console.log(extractIdField(str2)); // Expected output: "P3C0"
const str1 = "SEP_P1C2_GMP_ARL.L5K";
const str2 = "SEP_PxCy_GMP.L5K";
console.log(extractIdField(str1)); // Expected output: "P1C2"
console.log(extractIdField(str2)); // Expected output: "PxCy"</code></pre>
<h4 class="name" id=".fnc"><span class="type-signature">(static) </span>fnc<span class="signature">(message, source)</span><span class="type-signature"></span></h4>
<div class="description">
logs 'function call' showing call patterns to the Console in a standardized format.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>message</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">pre-formatted message to be logged.</td>
</tr>
<tr>
<td class="name"><code>source</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">where the message orginated.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line480">line 480</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
nothing.
</div>
<h4 class="name" id=".isJson"><span class="type-signature">(static) </span>isJson<span class="signature">(object)</span><span class="type-signature"> → {boolean}</span></h4>
<div class="description">
Checks a string for embedded JSON data.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>object</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">string to be tested</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line1188">line 1188</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
a value indicating whether or not the object contains a JSON string
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id=".isNumber"><span class="type-signature">(static) </span>isNumber<span class="signature">(numberToCheck)</span><span class="type-signature"> → {boolean}</span></h4>
<div class="description">
Checks for NaN.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>numberToCheck</code></td>
<td class="type">
<span class="param-type">any</span>
</td>
<td class="description last">as a number of some type</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line1173">line 1173</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
a value indicating whether or not it is NaN.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id=".isObject"><span class="type-signature">(static) </span>isObject<span class="signature">(jsObject)</span><span class="type-signature"> → {boolean}</span></h4>
<div class="description">
Checks whether or not a string is a JS Object.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>jsObject</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">string to be tested</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line1160">line 1160</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
a value indicating whether or not the string is a JS Object.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id=".isString"><span class="type-signature">(static) </span>isString<span class="signature">(object)</span><span class="type-signature"> → {boolean}</span></h4>
<div class="description">
Checks the type of an Object for String.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>object</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">to be tested</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line1147">line 1147</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
a value indicating whether or not the object is a string
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id=".isUndefined"><span class="type-signature">(static) </span>isUndefined<span class="signature">(objectToCheck)</span><span class="type-signature"> → {boolean}</span></h4>
<div class="description">
Checks for undefined.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>objectToCheck</code></td>
<td class="type">
<span class="param-type">any</span>
</td>
<td class="description last">as a variable of some type</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line1220">line 1220</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
a value indicating whether or not it is UNDEFINED.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id=".listifyArray"><span class="type-signature">(static) </span>listifyArray<span class="signature">(arrayToListify, outputType)</span><span class="type-signature"> → {string}</span></h4>
<div class="description">
Converts an array of text items into a HTML or JSX List.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>arrayToListify</code></td>
<td class="type">
<span class="param-type">Array.<any></span>
</td>
<td class="description last">the array to be convert to a HTML List.</td>
</tr>
<tr>
<td class="name"><code>outputType</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">how to out the list: 'html' or 'jsx'.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line999">line 999</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
the HTML List code.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".log"><span class="type-signature">(static) </span>log<span class="signature">(message, source, severity, error)</span><span class="type-signature"> → {string}</span></h4>
<div class="description">
Logs App Events to the Console in a standardized format.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>message</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">pre-formatted message to be logged.</td>
</tr>
<tr>
<td class="name"><code>source</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">where the message orginated.</td>
</tr>
<tr>
<td class="name"><code>severity</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">Event.Severity: 'info', 'warn', 'error', 'exception', and 'success'.</td>
</tr>
<tr>
<td class="name"><code>error</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">[Optional] error message from another source.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line229">line 229</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
"{severiy}: {message}" for display in UI.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>From our other MicroCODE Apps:
++
Message: 'Station SYNCHRONIZED to new Job from TRACKING IMAGE'
Class: JobIdZone Audience: Operator
Object: 8 Condition: Takt=[0%] Memory in use=[1,659,216.00]
Event: 14 Severity: Confirmation
Targets: AppLog, AppBanner, AppDatabase, AppSound
Event: (see 'Message:' above) Time: Tuesday, August 10, 2021 06:57:47.623 AM
Class: MicroCODE.AppBanner Type: App.Information CSN:[1GA4174210 ]
--</code></pre>
<h4 class="name" id=".logify"><span class="type-signature">(static) </span>logify<span class="signature">(textToLogify)</span><span class="type-signature"> → {string}</span></h4>
<div class="description">
Formats a string of BRACES, BRACKETS, QUOTES, for display in the EVENT LOG.
No formatting occurs until the opening brace '{' of the JSON Data. VT Escape sequences are stripped.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>textToLogify</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">the string to be formatted for the event log</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line636">line 636</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
the logified text
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".logifyObject"><span class="type-signature">(static) </span>logifyObject<span class="signature">(objectToLogify)</span><span class="type-signature"> → {string}</span></h4>
<div class="description">
Converts a JSON Object into loggable text, like JSON.stringify() but with more control.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>objectToLogify</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line875">line 875</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
the logified object
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".simplify"><span class="type-signature">(static) </span>simplify<span class="signature">(object)</span><span class="type-signature"> → {string}</span></h4>
<div class="description">
Strips a string of BRACES, BRACKETS, QUOTES, etc.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>object</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">the string to be simplified to data</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line528">line 528</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
the simplified text
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".simplifyObject"><span class="type-signature">(static) </span>simplifyObject<span class="signature">(objectToSimplify)</span><span class="type-signature"> → {string}</span></h4>
<div class="description">
Strips an object of BRACES, BRACKETS, QUOTES, etc.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>objectToSimplify</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">the object to be formatted for the event log</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line622">line 622</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
the simplified object
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".timestamp"><span class="type-signature">(static) </span>timestamp<span class="signature">(local)</span><span class="type-signature"> → {string}</span></h4>
<div class="description">
Generates timestamp string: YYYY-MM-DD Day HH:MM:SS.mmm.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>local</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="description last">[Optional] determines whether or not local time is used, if not it returns use UTC.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line1234">line 1234</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
"YYYY-MM-DD Day HH:MM:SS.mmm UTC|Local".
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Namespaces</h3><ul><li><a href="mcode.html">mcode</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Mon Jan 29 2024 09:25:29 GMT-0500 (Eastern Standard Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>