mirror of
https://github.com/misskey-dev/SyslogPro.git
synced 2025-04-29 02:37:18 +09:00
Merge pull request #1 from ajimix/master
Apply "Fix applicationName and includeStructuredData typos"
This commit is contained in:
commit
0607153266
@ -50,7 +50,7 @@ create formatted messages or use directly
|
|||||||
**RFC3164**
|
**RFC3164**
|
||||||
```js
|
```js
|
||||||
let rfc3164 = new SyslogPro.RFC3164({
|
let rfc3164 = new SyslogPro.RFC3164({
|
||||||
applacationName: 'MyApp',
|
applicationName: 'MyApp',
|
||||||
color: true,
|
color: true,
|
||||||
extendedColor: true,
|
extendedColor: true,
|
||||||
server: {
|
server: {
|
||||||
@ -63,9 +63,9 @@ create formatted messages or use directly
|
|||||||
**RFC5424**
|
**RFC5424**
|
||||||
```js
|
```js
|
||||||
let rfc5424 = new SyslogPro.RFC5424({
|
let rfc5424 = new SyslogPro.RFC5424({
|
||||||
applacationName: 'MyApp',
|
applicationName: 'MyApp',
|
||||||
timestamp: true,
|
timestamp: true,
|
||||||
encludeStructuredData: true
|
includeStructuredData: true
|
||||||
color: true,
|
color: true,
|
||||||
extendedColor: true,
|
extendedColor: true,
|
||||||
server: {
|
server: {
|
||||||
|
14
docs/api.md
14
docs/api.md
@ -65,7 +65,7 @@ formatting classes so that they may run independently.
|
|||||||
* [.timestampUTC](#module_SyslogPro..RFC5424+timestampUTC) : <code>boolean</code>
|
* [.timestampUTC](#module_SyslogPro..RFC5424+timestampUTC) : <code>boolean</code>
|
||||||
* [.timestampTZ](#module_SyslogPro..RFC5424+timestampTZ) : <code>boolean</code>
|
* [.timestampTZ](#module_SyslogPro..RFC5424+timestampTZ) : <code>boolean</code>
|
||||||
* [.timestampMS](#module_SyslogPro..RFC5424+timestampMS) : <code>boolean</code>
|
* [.timestampMS](#module_SyslogPro..RFC5424+timestampMS) : <code>boolean</code>
|
||||||
* [.encludeStructuredData](#module_SyslogPro..RFC5424+encludeStructuredData) : <code>boolean</code>
|
* [.includeStructuredData](#module_SyslogPro..RFC5424+includeStructuredData) : <code>boolean</code>
|
||||||
* [.utf8BOM](#module_SyslogPro..RFC5424+utf8BOM) : <code>boolean</code>
|
* [.utf8BOM](#module_SyslogPro..RFC5424+utf8BOM) : <code>boolean</code>
|
||||||
* [.color](#module_SyslogPro..RFC5424+color) : <code>boolean</code>
|
* [.color](#module_SyslogPro..RFC5424+color) : <code>boolean</code>
|
||||||
* [.extendedColor](#module_SyslogPro..RFC5424+extendedColor) : <code>boolean</code>
|
* [.extendedColor](#module_SyslogPro..RFC5424+extendedColor) : <code>boolean</code>
|
||||||
@ -263,7 +263,7 @@ Construct a new RFC3164 formatted Syslog object with user options
|
|||||||
| Param | Type | Default | Description |
|
| Param | Type | Default | Description |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| [options] | <code>object</code> | | Options object |
|
| [options] | <code>object</code> | | Options object |
|
||||||
| [options.applacationName] | <code>string</code> | <code>"'NodeJSLogger'"</code> | Application |
|
| [options.applicationName] | <code>string</code> | <code>"'NodeJSLogger'"</code> | Application |
|
||||||
| [options.hostname] | <code>string</code> | <code>"os.hostname"</code> | The name of this server |
|
| [options.hostname] | <code>string</code> | <code>"os.hostname"</code> | The name of this server |
|
||||||
| [options.facility] | <code>number</code> | <code>23</code> | Facility code to use sending this message |
|
| [options.facility] | <code>number</code> | <code>23</code> | Facility code to use sending this message |
|
||||||
| [options.color] | <code>boolean</code> | <code>false</code> | Apply color coding encoding tag with syslog message text |
|
| [options.color] | <code>boolean</code> | <code>false</code> | Apply color coding encoding tag with syslog message text |
|
||||||
@ -636,7 +636,7 @@ fashion where new messages are written to the class as needed.
|
|||||||
* [.timestampUTC](#module_SyslogPro..RFC5424+timestampUTC) : <code>boolean</code>
|
* [.timestampUTC](#module_SyslogPro..RFC5424+timestampUTC) : <code>boolean</code>
|
||||||
* [.timestampTZ](#module_SyslogPro..RFC5424+timestampTZ) : <code>boolean</code>
|
* [.timestampTZ](#module_SyslogPro..RFC5424+timestampTZ) : <code>boolean</code>
|
||||||
* [.timestampMS](#module_SyslogPro..RFC5424+timestampMS) : <code>boolean</code>
|
* [.timestampMS](#module_SyslogPro..RFC5424+timestampMS) : <code>boolean</code>
|
||||||
* [.encludeStructuredData](#module_SyslogPro..RFC5424+encludeStructuredData) : <code>boolean</code>
|
* [.includeStructuredData](#module_SyslogPro..RFC5424+includeStructuredData) : <code>boolean</code>
|
||||||
* [.utf8BOM](#module_SyslogPro..RFC5424+utf8BOM) : <code>boolean</code>
|
* [.utf8BOM](#module_SyslogPro..RFC5424+utf8BOM) : <code>boolean</code>
|
||||||
* [.color](#module_SyslogPro..RFC5424+color) : <code>boolean</code>
|
* [.color](#module_SyslogPro..RFC5424+color) : <code>boolean</code>
|
||||||
* [.extendedColor](#module_SyslogPro..RFC5424+extendedColor) : <code>boolean</code>
|
* [.extendedColor](#module_SyslogPro..RFC5424+extendedColor) : <code>boolean</code>
|
||||||
@ -668,13 +668,13 @@ Construct a new RFC5424 formatted Syslog object with user options
|
|||||||
| Param | Type | Default | Description |
|
| Param | Type | Default | Description |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| [options] | <code>object</code> | | Options object |
|
| [options] | <code>object</code> | | Options object |
|
||||||
| [options.applacationName] | <code>string</code> | <code>"'NodeJSLogger'"</code> | Application |
|
| [options.applicationName] | <code>string</code> | <code>"'NodeJSLogger'"</code> | Application |
|
||||||
| [options.hostname] | <code>string</code> | <code>"os.hostname"</code> | The name of this server |
|
| [options.hostname] | <code>string</code> | <code>"os.hostname"</code> | The name of this server |
|
||||||
| [options.timestamp] | <code>boolean</code> | <code>false</code> | Included a Timestamp |
|
| [options.timestamp] | <code>boolean</code> | <code>false</code> | Included a Timestamp |
|
||||||
| [options.timestampUTC] | <code>boolean</code> | <code>false</code> | RFC standard is for local time |
|
| [options.timestampUTC] | <code>boolean</code> | <code>false</code> | RFC standard is for local time |
|
||||||
| [options.timestampMS] | <code>boolean</code> | <code>false</code> | Timestamp with ms resolution |
|
| [options.timestampMS] | <code>boolean</code> | <code>false</code> | Timestamp with ms resolution |
|
||||||
| [options.timestampTZ] | <code>boolean</code> | <code>true</code> | Should the timestamp included time zone |
|
| [options.timestampTZ] | <code>boolean</code> | <code>true</code> | Should the timestamp included time zone |
|
||||||
| [options.encludeStructuredData] | <code>boolean</code> | <code>false</code> | Included any provided structured data |
|
| [options.includeStructuredData] | <code>boolean</code> | <code>false</code> | Included any provided structured data |
|
||||||
| [options.utf8BOM] | <code>boolean</code> | <code>true</code> | Included the UTF8 |
|
| [options.utf8BOM] | <code>boolean</code> | <code>true</code> | Included the UTF8 |
|
||||||
| [options.color] | <code>boolean</code> | <code>false</code> | Included the UTF8 |
|
| [options.color] | <code>boolean</code> | <code>false</code> | Included the UTF8 |
|
||||||
| [options.extendedColor] | <code>boolean</code> | <code>false</code> | Included the UTF8 encoding tag with syslog message text |
|
| [options.extendedColor] | <code>boolean</code> | <code>false</code> | Included the UTF8 encoding tag with syslog message text |
|
||||||
@ -705,9 +705,9 @@ Construct a new RFC5424 formatted Syslog object with user options
|
|||||||
|
|
||||||
#### rfC5424.timestampMS : <code>boolean</code>
|
#### rfC5424.timestampMS : <code>boolean</code>
|
||||||
**Kind**: instance property of [<code>RFC5424</code>](#module_SyslogPro..RFC5424)
|
**Kind**: instance property of [<code>RFC5424</code>](#module_SyslogPro..RFC5424)
|
||||||
<a name="module_SyslogPro..RFC5424+encludeStructuredData"></a>
|
<a name="module_SyslogPro..RFC5424+includeStructuredData"></a>
|
||||||
|
|
||||||
#### rfC5424.encludeStructuredData : <code>boolean</code>
|
#### rfC5424.includeStructuredData : <code>boolean</code>
|
||||||
**Kind**: instance property of [<code>RFC5424</code>](#module_SyslogPro..RFC5424)
|
**Kind**: instance property of [<code>RFC5424</code>](#module_SyslogPro..RFC5424)
|
||||||
<a name="module_SyslogPro..RFC5424+utf8BOM"></a>
|
<a name="module_SyslogPro..RFC5424+utf8BOM"></a>
|
||||||
|
|
||||||
|
@ -624,7 +624,7 @@ class RFC3164 {
|
|||||||
* @public
|
* @public
|
||||||
* @this RFC3164
|
* @this RFC3164
|
||||||
* @param {object} [options] - Options object
|
* @param {object} [options] - Options object
|
||||||
* @param {string} [options.applacationName='NodeJSLogger'] - Application
|
* @param {string} [options.applicationName='NodeJSLogger'] - Application
|
||||||
* @param {string} [options.hostname=os.hostname] - The name of this server
|
* @param {string} [options.hostname=os.hostname] - The name of this server
|
||||||
* @param {number} [options.facility=23] - Facility code to use sending this
|
* @param {number} [options.facility=23] - Facility code to use sending this
|
||||||
* message
|
* message
|
||||||
@ -667,7 +667,7 @@ class RFC3164 {
|
|||||||
this.constructor__ = true;
|
this.constructor__ = true;
|
||||||
options = options || {};
|
options = options || {};
|
||||||
this.hostname = options.hostname || os.hostname();
|
this.hostname = options.hostname || os.hostname();
|
||||||
this.applacationName = options.applacationName || '';
|
this.applicationName = options.applicationName || '';
|
||||||
this.facility = options.facility || 23;
|
this.facility = options.facility || 23;
|
||||||
if (options.color) {
|
if (options.color) {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
@ -1016,7 +1016,7 @@ Build message
|
|||||||
fmtMsg = '<' + pri + '>';
|
fmtMsg = '<' + pri + '>';
|
||||||
fmtMsg += timestamp;
|
fmtMsg += timestamp;
|
||||||
fmtMsg += ' ' + this.hostname;
|
fmtMsg += ' ' + this.hostname;
|
||||||
fmtMsg += ' ' + this.applacationName;
|
fmtMsg += ' ' + this.applicationName;
|
||||||
fmtMsg += ' ' + msg;
|
fmtMsg += ' ' + msg;
|
||||||
fmtMsg += newLine;
|
fmtMsg += newLine;
|
||||||
resolve(fmtMsg);
|
resolve(fmtMsg);
|
||||||
@ -1258,7 +1258,7 @@ class RFC5424 {
|
|||||||
* @public
|
* @public
|
||||||
* @this RFC5424
|
* @this RFC5424
|
||||||
* @param {object} [options] - Options object
|
* @param {object} [options] - Options object
|
||||||
* @param {string} [options.applacationName='NodeJSLogger'] - Application
|
* @param {string} [options.applicationName='NodeJSLogger'] - Application
|
||||||
* @param {string} [options.hostname=os.hostname] - The name of this server
|
* @param {string} [options.hostname=os.hostname] - The name of this server
|
||||||
* @param {boolean} [options.timestamp=false] - Included a Timestamp
|
* @param {boolean} [options.timestamp=false] - Included a Timestamp
|
||||||
* @param {boolean} [options.timestampUTC=false] - RFC standard is for
|
* @param {boolean} [options.timestampUTC=false] - RFC standard is for
|
||||||
@ -1267,7 +1267,7 @@ class RFC5424 {
|
|||||||
* resolution
|
* resolution
|
||||||
* @param {boolean} [options.timestampTZ=true] - Should the timestamp
|
* @param {boolean} [options.timestampTZ=true] - Should the timestamp
|
||||||
* included time zone
|
* included time zone
|
||||||
* @param {boolean} [options.encludeStructuredData=false] - Included
|
* @param {boolean} [options.includeStructuredData=false] - Included
|
||||||
* any provided structured data
|
* any provided structured data
|
||||||
* @param {boolean} [options.utf8BOM=true] - Included the UTF8
|
* @param {boolean} [options.utf8BOM=true] - Included the UTF8
|
||||||
* @param {boolean} [options.color=false] - Included the UTF8
|
* @param {boolean} [options.color=false] - Included the UTF8
|
||||||
@ -1308,7 +1308,7 @@ class RFC5424 {
|
|||||||
this.constructor__ = true;
|
this.constructor__ = true;
|
||||||
options = options || {};
|
options = options || {};
|
||||||
this.hostname = options.hostname || os.hostname();
|
this.hostname = options.hostname || os.hostname();
|
||||||
this.applacationName = options.applacationName || '';
|
this.applicationName = options.applicationName || '';
|
||||||
if (typeof options.timestamp === 'undefined' || options.timestamp) {
|
if (typeof options.timestamp === 'undefined' || options.timestamp) {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
this.timestamp = true;
|
this.timestamp = true;
|
||||||
@ -1333,11 +1333,11 @@ class RFC5424 {
|
|||||||
} else {
|
} else {
|
||||||
this.timestampMS = false;
|
this.timestampMS = false;
|
||||||
}
|
}
|
||||||
if (options.encludeStructuredData) {
|
if (options.includeStructuredData) {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
this.encludeStructuredData = true;
|
this.includeStructuredData = true;
|
||||||
} else {
|
} else {
|
||||||
this.encludeStructuredData = false;
|
this.includeStructuredData = false;
|
||||||
}
|
}
|
||||||
if (typeof options.utf8BOM === 'undefined' || options.utf8BOM) {
|
if (typeof options.utf8BOM === 'undefined' || options.utf8BOM) {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
@ -1740,7 +1740,7 @@ Build Structured Data string
|
|||||||
```
|
```
|
||||||
let structuredData = '-';
|
let structuredData = '-';
|
||||||
const sdElementCount = msgStructuredData.length;
|
const sdElementCount = msgStructuredData.length;
|
||||||
if (this.encludeStructuredData && sdElementCount > 0) {
|
if (this.includeStructuredData && sdElementCount > 0) {
|
||||||
let sdElementNames = [];
|
let sdElementNames = [];
|
||||||
let sdElements = [];
|
let sdElements = [];
|
||||||
const sdElementNameRegEx = /(\[)(\S*)(\s|\])/;
|
const sdElementNameRegEx = /(\[)(\S*)(\s|\])/;
|
||||||
@ -1791,7 +1791,7 @@ Build the message
|
|||||||
fmtMsg += '1'; // Version number
|
fmtMsg += '1'; // Version number
|
||||||
fmtMsg += ' ' + timestamp;
|
fmtMsg += ' ' + timestamp;
|
||||||
fmtMsg += ' ' + this.hostname;
|
fmtMsg += ' ' + this.hostname;
|
||||||
fmtMsg += ' ' + this.applacationName;
|
fmtMsg += ' ' + this.applicationName;
|
||||||
fmtMsg += ' ' + pid;
|
fmtMsg += ' ' + pid;
|
||||||
fmtMsg += ' ' + id;
|
fmtMsg += ' ' + id;
|
||||||
fmtMsg += ' ' + structuredData;
|
fmtMsg += ' ' + structuredData;
|
||||||
|
@ -637,7 +637,7 @@
|
|||||||
* @public
|
* @public
|
||||||
* @this RFC3164
|
* @this RFC3164
|
||||||
* @param {object} [options] - Options object
|
* @param {object} [options] - Options object
|
||||||
* @param {string} [options.applacationName='NodeJSLogger'] - Application
|
* @param {string} [options.applicationName='NodeJSLogger'] - Application
|
||||||
* @param {string} [options.hostname=os.hostname] - The name of this server
|
* @param {string} [options.hostname=os.hostname] - The name of this server
|
||||||
* @param {number} [options.facility=23] - Facility code to use sending this
|
* @param {number} [options.facility=23] - Facility code to use sending this
|
||||||
* message
|
* message
|
||||||
@ -680,7 +680,7 @@
|
|||||||
<span class="hljs-keyword">this</span>.constructor__ = <span class="hljs-literal">true</span>;
|
<span class="hljs-keyword">this</span>.constructor__ = <span class="hljs-literal">true</span>;
|
||||||
options = options || {};
|
options = options || {};
|
||||||
<span class="hljs-keyword">this</span>.hostname = options.hostname || os.hostname();
|
<span class="hljs-keyword">this</span>.hostname = options.hostname || os.hostname();
|
||||||
<span class="hljs-keyword">this</span>.applacationName = options.applacationName || <span class="hljs-string">''</span>;
|
<span class="hljs-keyword">this</span>.applicationName = options.applicationName || <span class="hljs-string">''</span>;
|
||||||
<span class="hljs-keyword">this</span>.facility = options.facility || <span class="hljs-number">23</span>;
|
<span class="hljs-keyword">this</span>.facility = options.facility || <span class="hljs-number">23</span>;
|
||||||
<span class="hljs-keyword">if</span> (options.color) {
|
<span class="hljs-keyword">if</span> (options.color) {
|
||||||
<span class="hljs-comment">/** @type {boolean} */</span>
|
<span class="hljs-comment">/** @type {boolean} */</span>
|
||||||
@ -1024,7 +1024,7 @@ uses BSD timeformat</p>
|
|||||||
<div class="content"><div class='highlight'><pre> fmtMsg = <span class="hljs-string">'<'</span> + pri + <span class="hljs-string">'>'</span>;
|
<div class="content"><div class='highlight'><pre> fmtMsg = <span class="hljs-string">'<'</span> + pri + <span class="hljs-string">'>'</span>;
|
||||||
fmtMsg += timestamp;
|
fmtMsg += timestamp;
|
||||||
fmtMsg += <span class="hljs-string">' '</span> + <span class="hljs-keyword">this</span>.hostname;
|
fmtMsg += <span class="hljs-string">' '</span> + <span class="hljs-keyword">this</span>.hostname;
|
||||||
fmtMsg += <span class="hljs-string">' '</span> + <span class="hljs-keyword">this</span>.applacationName;
|
fmtMsg += <span class="hljs-string">' '</span> + <span class="hljs-keyword">this</span>.applicationName;
|
||||||
fmtMsg += <span class="hljs-string">' '</span> + msg;
|
fmtMsg += <span class="hljs-string">' '</span> + msg;
|
||||||
fmtMsg += newLine;
|
fmtMsg += newLine;
|
||||||
resolve(fmtMsg);
|
resolve(fmtMsg);
|
||||||
@ -1266,7 +1266,7 @@ uses BSD timeformat</p>
|
|||||||
* @public
|
* @public
|
||||||
* @this RFC5424
|
* @this RFC5424
|
||||||
* @param {object} [options] - Options object
|
* @param {object} [options] - Options object
|
||||||
* @param {string} [options.applacationName='NodeJSLogger'] - Application
|
* @param {string} [options.applicationName='NodeJSLogger'] - Application
|
||||||
* @param {string} [options.hostname=os.hostname] - The name of this server
|
* @param {string} [options.hostname=os.hostname] - The name of this server
|
||||||
* @param {boolean} [options.timestamp=false] - Included a Timestamp
|
* @param {boolean} [options.timestamp=false] - Included a Timestamp
|
||||||
* @param {boolean} [options.timestampUTC=false] - RFC standard is for
|
* @param {boolean} [options.timestampUTC=false] - RFC standard is for
|
||||||
@ -1275,7 +1275,7 @@ uses BSD timeformat</p>
|
|||||||
* resolution
|
* resolution
|
||||||
* @param {boolean} [options.timestampTZ=true] - Should the timestamp
|
* @param {boolean} [options.timestampTZ=true] - Should the timestamp
|
||||||
* included time zone
|
* included time zone
|
||||||
* @param {boolean} [options.encludeStructuredData=false] - Included
|
* @param {boolean} [options.includeStructuredData=false] - Included
|
||||||
* any provided structured data
|
* any provided structured data
|
||||||
* @param {boolean} [options.utf8BOM=true] - Included the UTF8
|
* @param {boolean} [options.utf8BOM=true] - Included the UTF8
|
||||||
* @param {boolean} [options.color=false] - Included the UTF8
|
* @param {boolean} [options.color=false] - Included the UTF8
|
||||||
@ -1316,7 +1316,7 @@ uses BSD timeformat</p>
|
|||||||
<span class="hljs-keyword">this</span>.constructor__ = <span class="hljs-literal">true</span>;
|
<span class="hljs-keyword">this</span>.constructor__ = <span class="hljs-literal">true</span>;
|
||||||
options = options || {};
|
options = options || {};
|
||||||
<span class="hljs-keyword">this</span>.hostname = options.hostname || os.hostname();
|
<span class="hljs-keyword">this</span>.hostname = options.hostname || os.hostname();
|
||||||
<span class="hljs-keyword">this</span>.applacationName = options.applacationName || <span class="hljs-string">''</span>;
|
<span class="hljs-keyword">this</span>.applicationName = options.applicationName || <span class="hljs-string">''</span>;
|
||||||
<span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> options.timestamp === <span class="hljs-string">'undefined'</span> || options.timestamp) {
|
<span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> options.timestamp === <span class="hljs-string">'undefined'</span> || options.timestamp) {
|
||||||
<span class="hljs-comment">/** @type {boolean} */</span>
|
<span class="hljs-comment">/** @type {boolean} */</span>
|
||||||
<span class="hljs-keyword">this</span>.timestamp = <span class="hljs-literal">true</span>;
|
<span class="hljs-keyword">this</span>.timestamp = <span class="hljs-literal">true</span>;
|
||||||
@ -1341,11 +1341,11 @@ uses BSD timeformat</p>
|
|||||||
} <span class="hljs-keyword">else</span> {
|
} <span class="hljs-keyword">else</span> {
|
||||||
<span class="hljs-keyword">this</span>.timestampMS = <span class="hljs-literal">false</span>;
|
<span class="hljs-keyword">this</span>.timestampMS = <span class="hljs-literal">false</span>;
|
||||||
}
|
}
|
||||||
<span class="hljs-keyword">if</span> (options.encludeStructuredData) {
|
<span class="hljs-keyword">if</span> (options.includeStructuredData) {
|
||||||
<span class="hljs-comment">/** @type {boolean} */</span>
|
<span class="hljs-comment">/** @type {boolean} */</span>
|
||||||
<span class="hljs-keyword">this</span>.encludeStructuredData = <span class="hljs-literal">true</span>;
|
<span class="hljs-keyword">this</span>.includeStructuredData = <span class="hljs-literal">true</span>;
|
||||||
} <span class="hljs-keyword">else</span> {
|
} <span class="hljs-keyword">else</span> {
|
||||||
<span class="hljs-keyword">this</span>.encludeStructuredData = <span class="hljs-literal">false</span>;
|
<span class="hljs-keyword">this</span>.includeStructuredData = <span class="hljs-literal">false</span>;
|
||||||
}
|
}
|
||||||
<span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> options.utf8BOM === <span class="hljs-string">'undefined'</span> || options.utf8BOM) {
|
<span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> options.utf8BOM === <span class="hljs-string">'undefined'</span> || options.utf8BOM) {
|
||||||
<span class="hljs-comment">/** @type {boolean} */</span>
|
<span class="hljs-comment">/** @type {boolean} */</span>
|
||||||
@ -1743,7 +1743,7 @@ uses BSD timeformat</p>
|
|||||||
|
|
||||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">let</span> structuredData = <span class="hljs-string">'-'</span>;
|
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">let</span> structuredData = <span class="hljs-string">'-'</span>;
|
||||||
<span class="hljs-keyword">const</span> sdElementCount = msgStructuredData.length;
|
<span class="hljs-keyword">const</span> sdElementCount = msgStructuredData.length;
|
||||||
<span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>.encludeStructuredData && sdElementCount > <span class="hljs-number">0</span>) {
|
<span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>.includeStructuredData && sdElementCount > <span class="hljs-number">0</span>) {
|
||||||
<span class="hljs-keyword">let</span> sdElementNames = [];
|
<span class="hljs-keyword">let</span> sdElementNames = [];
|
||||||
<span class="hljs-keyword">let</span> sdElements = [];
|
<span class="hljs-keyword">let</span> sdElements = [];
|
||||||
<span class="hljs-keyword">const</span> sdElementNameRegEx = <span class="hljs-regexp">/(\[)(\S*)(\s|\])/</span>;</pre></div></div>
|
<span class="hljs-keyword">const</span> sdElementNameRegEx = <span class="hljs-regexp">/(\[)(\S*)(\s|\])/</span>;</pre></div></div>
|
||||||
@ -1792,7 +1792,7 @@ uses BSD timeformat</p>
|
|||||||
fmtMsg += <span class="hljs-string">'1'</span>; <span class="hljs-comment">// Version number</span>
|
fmtMsg += <span class="hljs-string">'1'</span>; <span class="hljs-comment">// Version number</span>
|
||||||
fmtMsg += <span class="hljs-string">' '</span> + timestamp;
|
fmtMsg += <span class="hljs-string">' '</span> + timestamp;
|
||||||
fmtMsg += <span class="hljs-string">' '</span> + <span class="hljs-keyword">this</span>.hostname;
|
fmtMsg += <span class="hljs-string">' '</span> + <span class="hljs-keyword">this</span>.hostname;
|
||||||
fmtMsg += <span class="hljs-string">' '</span> + <span class="hljs-keyword">this</span>.applacationName;
|
fmtMsg += <span class="hljs-string">' '</span> + <span class="hljs-keyword">this</span>.applicationName;
|
||||||
fmtMsg += <span class="hljs-string">' '</span> + pid;
|
fmtMsg += <span class="hljs-string">' '</span> + pid;
|
||||||
fmtMsg += <span class="hljs-string">' '</span> + id;
|
fmtMsg += <span class="hljs-string">' '</span> + id;
|
||||||
fmtMsg += <span class="hljs-string">' '</span> + structuredData;
|
fmtMsg += <span class="hljs-string">' '</span> + structuredData;
|
||||||
|
@ -85,7 +85,7 @@ and the <a href="https://nodejs.org/api/dns.html#dns_dns_promises_api">DNS Promi
|
|||||||
create formatted messages or use directly</p>
|
create formatted messages or use directly</p>
|
||||||
<p><strong>RFC3164</strong></p>
|
<p><strong>RFC3164</strong></p>
|
||||||
<pre class="prettyprint source lang-js"><code> let rfc3164 = new SyslogPro.RFC3164({
|
<pre class="prettyprint source lang-js"><code> let rfc3164 = new SyslogPro.RFC3164({
|
||||||
applacationName: 'MyApp',
|
applicationName: 'MyApp',
|
||||||
color: true,
|
color: true,
|
||||||
extendedColor: true,
|
extendedColor: true,
|
||||||
server: {
|
server: {
|
||||||
@ -94,9 +94,9 @@ create formatted messages or use directly</p>
|
|||||||
});
|
});
|
||||||
rfc3164.info('My Message');</code></pre><p><strong>RFC5424</strong></p>
|
rfc3164.info('My Message');</code></pre><p><strong>RFC5424</strong></p>
|
||||||
<pre class="prettyprint source lang-js"><code> let rfc5424 = new SyslogPro.RFC5424({
|
<pre class="prettyprint source lang-js"><code> let rfc5424 = new SyslogPro.RFC5424({
|
||||||
applacationName: 'MyApp',
|
applicationName: 'MyApp',
|
||||||
timestamp: true,
|
timestamp: true,
|
||||||
encludeStructuredData: true
|
includeStructuredData: true
|
||||||
color: true,
|
color: true,
|
||||||
extendedColor: true,
|
extendedColor: true,
|
||||||
server: {
|
server: {
|
||||||
|
@ -518,7 +518,7 @@ class RFC3164 {
|
|||||||
* @public
|
* @public
|
||||||
* @this RFC3164
|
* @this RFC3164
|
||||||
* @param {object} [options] - Options object
|
* @param {object} [options] - Options object
|
||||||
* @param {string} [options.applacationName='NodeJSLogger'] - Application
|
* @param {string} [options.applicationName='NodeJSLogger'] - Application
|
||||||
* @param {string} [options.hostname=os.hostname] - The name of this server
|
* @param {string} [options.hostname=os.hostname] - The name of this server
|
||||||
* @param {number} [options.facility=23] - Facility code to use sending this
|
* @param {number} [options.facility=23] - Facility code to use sending this
|
||||||
* message
|
* message
|
||||||
@ -561,7 +561,7 @@ class RFC3164 {
|
|||||||
this.constructor__ = true;
|
this.constructor__ = true;
|
||||||
options = options || {};
|
options = options || {};
|
||||||
this.hostname = options.hostname || os.hostname();
|
this.hostname = options.hostname || os.hostname();
|
||||||
this.applacationName = options.applacationName || '';
|
this.applicationName = options.applicationName || '';
|
||||||
this.facility = options.facility || 23;
|
this.facility = options.facility || 23;
|
||||||
if (options.color) {
|
if (options.color) {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
@ -840,7 +840,7 @@ class RFC3164 {
|
|||||||
fmtMsg = '<' + pri + '>';
|
fmtMsg = '<' + pri + '>';
|
||||||
fmtMsg += timestamp;
|
fmtMsg += timestamp;
|
||||||
fmtMsg += ' ' + this.hostname;
|
fmtMsg += ' ' + this.hostname;
|
||||||
fmtMsg += ' ' + this.applacationName;
|
fmtMsg += ' ' + this.applicationName;
|
||||||
fmtMsg += ' ' + msg;
|
fmtMsg += ' ' + msg;
|
||||||
fmtMsg += newLine;
|
fmtMsg += newLine;
|
||||||
resolve(fmtMsg);
|
resolve(fmtMsg);
|
||||||
@ -1082,7 +1082,7 @@ class RFC5424 {
|
|||||||
* @public
|
* @public
|
||||||
* @this RFC5424
|
* @this RFC5424
|
||||||
* @param {object} [options] - Options object
|
* @param {object} [options] - Options object
|
||||||
* @param {string} [options.applacationName='NodeJSLogger'] - Application
|
* @param {string} [options.applicationName='NodeJSLogger'] - Application
|
||||||
* @param {string} [options.hostname=os.hostname] - The name of this server
|
* @param {string} [options.hostname=os.hostname] - The name of this server
|
||||||
* @param {boolean} [options.timestamp=false] - Included a Timestamp
|
* @param {boolean} [options.timestamp=false] - Included a Timestamp
|
||||||
* @param {boolean} [options.timestampUTC=false] - RFC standard is for
|
* @param {boolean} [options.timestampUTC=false] - RFC standard is for
|
||||||
@ -1091,7 +1091,7 @@ class RFC5424 {
|
|||||||
* resolution
|
* resolution
|
||||||
* @param {boolean} [options.timestampTZ=true] - Should the timestamp
|
* @param {boolean} [options.timestampTZ=true] - Should the timestamp
|
||||||
* included time zone
|
* included time zone
|
||||||
* @param {boolean} [options.encludeStructuredData=false] - Included
|
* @param {boolean} [options.includeStructuredData=false] - Included
|
||||||
* any provided structured data
|
* any provided structured data
|
||||||
* @param {boolean} [options.utf8BOM=true] - Included the UTF8
|
* @param {boolean} [options.utf8BOM=true] - Included the UTF8
|
||||||
* @param {boolean} [options.color=false] - Included the UTF8
|
* @param {boolean} [options.color=false] - Included the UTF8
|
||||||
@ -1132,7 +1132,7 @@ class RFC5424 {
|
|||||||
this.constructor__ = true;
|
this.constructor__ = true;
|
||||||
options = options || {};
|
options = options || {};
|
||||||
this.hostname = options.hostname || os.hostname();
|
this.hostname = options.hostname || os.hostname();
|
||||||
this.applacationName = options.applacationName || '';
|
this.applicationName = options.applicationName || '';
|
||||||
if (typeof options.timestamp === 'undefined' || options.timestamp) {
|
if (typeof options.timestamp === 'undefined' || options.timestamp) {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
this.timestamp = true;
|
this.timestamp = true;
|
||||||
@ -1157,11 +1157,11 @@ class RFC5424 {
|
|||||||
} else {
|
} else {
|
||||||
this.timestampMS = false;
|
this.timestampMS = false;
|
||||||
}
|
}
|
||||||
if (options.encludeStructuredData) {
|
if (options.includeStructuredData) {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
this.encludeStructuredData = true;
|
this.includeStructuredData = true;
|
||||||
} else {
|
} else {
|
||||||
this.encludeStructuredData = false;
|
this.includeStructuredData = false;
|
||||||
}
|
}
|
||||||
if (typeof options.utf8BOM === 'undefined' || options.utf8BOM) {
|
if (typeof options.utf8BOM === 'undefined' || options.utf8BOM) {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
@ -1494,7 +1494,7 @@ class RFC5424 {
|
|||||||
// Build Structured Data string
|
// Build Structured Data string
|
||||||
let structuredData = '-';
|
let structuredData = '-';
|
||||||
const sdElementCount = msgStructuredData.length;
|
const sdElementCount = msgStructuredData.length;
|
||||||
if (this.encludeStructuredData && sdElementCount > 0) {
|
if (this.includeStructuredData && sdElementCount > 0) {
|
||||||
let sdElementNames = [];
|
let sdElementNames = [];
|
||||||
let sdElements = [];
|
let sdElements = [];
|
||||||
const sdElementNameRegEx = /(\[)(\S*)(\s|\])/;
|
const sdElementNameRegEx = /(\[)(\S*)(\s|\])/;
|
||||||
@ -1517,7 +1517,7 @@ class RFC5424 {
|
|||||||
fmtMsg += '1'; // Version number
|
fmtMsg += '1'; // Version number
|
||||||
fmtMsg += ' ' + timestamp;
|
fmtMsg += ' ' + timestamp;
|
||||||
fmtMsg += ' ' + this.hostname;
|
fmtMsg += ' ' + this.hostname;
|
||||||
fmtMsg += ' ' + this.applacationName;
|
fmtMsg += ' ' + this.applicationName;
|
||||||
fmtMsg += ' ' + pid;
|
fmtMsg += ' ' + pid;
|
||||||
fmtMsg += ' ' + id;
|
fmtMsg += ' ' + id;
|
||||||
fmtMsg += ' ' + structuredData;
|
fmtMsg += ' ' + structuredData;
|
||||||
|
@ -229,7 +229,7 @@ fashion where new messages are written to the class as needed.</div>
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<td class="name"><code>applacationName</code></td>
|
<td class="name"><code>applicationName</code></td>
|
||||||
|
|
||||||
|
|
||||||
<td class="type">
|
<td class="type">
|
||||||
|
@ -230,7 +230,7 @@ fashion where new messages are written to the class as needed.</div>
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<td class="name"><code>applacationName</code></td>
|
<td class="name"><code>applicationName</code></td>
|
||||||
|
|
||||||
|
|
||||||
<td class="type">
|
<td class="type">
|
||||||
@ -467,7 +467,7 @@ fashion where new messages are written to the class as needed.</div>
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<td class="name"><code>encludeStructuredData</code></td>
|
<td class="name"><code>includeStructuredData</code></td>
|
||||||
|
|
||||||
|
|
||||||
<td class="type">
|
<td class="type">
|
||||||
@ -1427,7 +1427,7 @@ fashion where new messages are written to the class as needed.</div>
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="encludeStructuredData"><span class="type-signature"></span>encludeStructuredData<span class="type-signature"> :boolean</span></h4>
|
<h4 class="name" id="includeStructuredData"><span class="type-signature"></span>includeStructuredData<span class="type-signature"> :boolean</span></h4>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
31
index.js
31
index.js
@ -475,7 +475,7 @@ class RFC3164 {
|
|||||||
* @public
|
* @public
|
||||||
* @this RFC3164
|
* @this RFC3164
|
||||||
* @param {object} [options] - Options object
|
* @param {object} [options] - Options object
|
||||||
* @param {string} [options.applacationName='NodeJSLogger'] - Application
|
* @param {string} [options.applicationName='NodeJSLogger'] - Application
|
||||||
* @param {string} [options.hostname=os.hostname] - The name of this server
|
* @param {string} [options.hostname=os.hostname] - The name of this server
|
||||||
* @param {number} [options.facility=23] - Facility code to use sending this
|
* @param {number} [options.facility=23] - Facility code to use sending this
|
||||||
* message
|
* message
|
||||||
@ -518,7 +518,11 @@ class RFC3164 {
|
|||||||
this.constructor__ = true;
|
this.constructor__ = true;
|
||||||
options = options || {};
|
options = options || {};
|
||||||
this.hostname = options.hostname || os.hostname();
|
this.hostname = options.hostname || os.hostname();
|
||||||
this.applacationName = options.applacationName || '';
|
if (options.applicationName) {
|
||||||
|
this.applicationName = options.applicationName;
|
||||||
|
} else {
|
||||||
|
this.applicationName = options.applacationName || '';
|
||||||
|
}
|
||||||
this.facility = options.facility || 23;
|
this.facility = options.facility || 23;
|
||||||
if (options.color) {
|
if (options.color) {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
@ -797,7 +801,7 @@ class RFC3164 {
|
|||||||
fmtMsg = '<' + pri + '>';
|
fmtMsg = '<' + pri + '>';
|
||||||
fmtMsg += timestamp;
|
fmtMsg += timestamp;
|
||||||
fmtMsg += ' ' + this.hostname;
|
fmtMsg += ' ' + this.hostname;
|
||||||
fmtMsg += ' ' + this.applacationName;
|
fmtMsg += ' ' + this.applicationName;
|
||||||
fmtMsg += ' ' + msg;
|
fmtMsg += ' ' + msg;
|
||||||
fmtMsg += newLine;
|
fmtMsg += newLine;
|
||||||
resolve(fmtMsg);
|
resolve(fmtMsg);
|
||||||
@ -1039,7 +1043,7 @@ class RFC5424 {
|
|||||||
* @public
|
* @public
|
||||||
* @this RFC5424
|
* @this RFC5424
|
||||||
* @param {object} [options] - Options object
|
* @param {object} [options] - Options object
|
||||||
* @param {string} [options.applacationName='NodeJSLogger'] - Application
|
* @param {string} [options.applicationName='NodeJSLogger'] - Application
|
||||||
* @param {string} [options.hostname=os.hostname] - The name of this server
|
* @param {string} [options.hostname=os.hostname] - The name of this server
|
||||||
* @param {boolean} [options.timestamp=false] - Included a Timestamp
|
* @param {boolean} [options.timestamp=false] - Included a Timestamp
|
||||||
* @param {boolean} [options.timestampUTC=false] - RFC standard is for
|
* @param {boolean} [options.timestampUTC=false] - RFC standard is for
|
||||||
@ -1048,7 +1052,7 @@ class RFC5424 {
|
|||||||
* resolution
|
* resolution
|
||||||
* @param {boolean} [options.timestampTZ=true] - Should the timestamp
|
* @param {boolean} [options.timestampTZ=true] - Should the timestamp
|
||||||
* included time zone
|
* included time zone
|
||||||
* @param {boolean} [options.encludeStructuredData=false] - Included
|
* @param {boolean} [options.includeStructuredData=false] - Included
|
||||||
* any provided structured data
|
* any provided structured data
|
||||||
* @param {boolean} [options.utf8BOM=true] - Included the UTF8
|
* @param {boolean} [options.utf8BOM=true] - Included the UTF8
|
||||||
* @param {boolean} [options.color=false] - Included the UTF8
|
* @param {boolean} [options.color=false] - Included the UTF8
|
||||||
@ -1089,7 +1093,11 @@ class RFC5424 {
|
|||||||
this.constructor__ = true;
|
this.constructor__ = true;
|
||||||
options = options || {};
|
options = options || {};
|
||||||
this.hostname = options.hostname || os.hostname();
|
this.hostname = options.hostname || os.hostname();
|
||||||
this.applacationName = options.applacationName || '';
|
if (options.applicationName) {
|
||||||
|
this.applicationName = options.applicationName;
|
||||||
|
} else {
|
||||||
|
this.applicationName = options.applacationName || '';
|
||||||
|
}
|
||||||
if (typeof options.timestamp === 'undefined' || options.timestamp) {
|
if (typeof options.timestamp === 'undefined' || options.timestamp) {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
this.timestamp = true;
|
this.timestamp = true;
|
||||||
@ -1114,11 +1122,11 @@ class RFC5424 {
|
|||||||
} else {
|
} else {
|
||||||
this.timestampMS = false;
|
this.timestampMS = false;
|
||||||
}
|
}
|
||||||
if (options.encludeStructuredData) {
|
if (options.includeStructuredData || options.encludeStructuredData) {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
this.encludeStructuredData = true;
|
this.includeStructuredData = true;
|
||||||
} else {
|
} else {
|
||||||
this.encludeStructuredData = false;
|
this.includeStructuredData = false;
|
||||||
}
|
}
|
||||||
if (typeof options.utf8BOM === 'undefined' || options.utf8BOM) {
|
if (typeof options.utf8BOM === 'undefined' || options.utf8BOM) {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
@ -1451,7 +1459,7 @@ class RFC5424 {
|
|||||||
// Build Structured Data string
|
// Build Structured Data string
|
||||||
let structuredData = '-';
|
let structuredData = '-';
|
||||||
const sdElementCount = msgStructuredData.length;
|
const sdElementCount = msgStructuredData.length;
|
||||||
if (this.encludeStructuredData && sdElementCount > 0) {
|
if (this.includeStructuredData && sdElementCount > 0) {
|
||||||
let sdElementNames = [];
|
let sdElementNames = [];
|
||||||
let sdElements = [];
|
let sdElements = [];
|
||||||
const sdElementNameRegEx = /(\[)(\S*)(\s|\])/;
|
const sdElementNameRegEx = /(\[)(\S*)(\s|\])/;
|
||||||
@ -1474,7 +1482,7 @@ class RFC5424 {
|
|||||||
fmtMsg += '1'; // Version number
|
fmtMsg += '1'; // Version number
|
||||||
fmtMsg += ' ' + timestamp;
|
fmtMsg += ' ' + timestamp;
|
||||||
fmtMsg += ' ' + this.hostname;
|
fmtMsg += ' ' + this.hostname;
|
||||||
fmtMsg += ' ' + this.applacationName;
|
fmtMsg += ' ' + this.applicationName;
|
||||||
fmtMsg += ' ' + pid;
|
fmtMsg += ' ' + pid;
|
||||||
fmtMsg += ' ' + id;
|
fmtMsg += ' ' + id;
|
||||||
fmtMsg += ' ' + structuredData;
|
fmtMsg += ' ' + structuredData;
|
||||||
@ -3374,4 +3382,3 @@ module.exports = {
|
|||||||
CEF: CEF,
|
CEF: CEF,
|
||||||
Syslog: Syslog,
|
Syslog: Syslog,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -373,7 +373,7 @@ describe('RFC5424 Class Tests', () => {
|
|||||||
timestampUTC: true,
|
timestampUTC: true,
|
||||||
timestampTZ: false,
|
timestampTZ: false,
|
||||||
timestampMS: true,
|
timestampMS: true,
|
||||||
encludeStructuredData: true,
|
includeStructuredData: true,
|
||||||
colors: {
|
colors: {
|
||||||
emergencyColor: 30,
|
emergencyColor: 30,
|
||||||
alertColor: 30,
|
alertColor: 30,
|
||||||
@ -428,7 +428,7 @@ describe('RFC5424 Class Tests', () => {
|
|||||||
let resultMsg = /<190>1 \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2} /;
|
let resultMsg = /<190>1 \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2} /;
|
||||||
expect(result).toMatch(resultMsg);
|
expect(result).toMatch(resultMsg);
|
||||||
let rfc5424 = new SyslogPro.RFC5424({
|
let rfc5424 = new SyslogPro.RFC5424({
|
||||||
encludeStructuredData: true,
|
includeStructuredData: true,
|
||||||
color: true,
|
color: true,
|
||||||
extendedColor: false,
|
extendedColor: false,
|
||||||
timestamp: true,
|
timestamp: true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user