Skip to content

Commit

Permalink
Better fix for #49
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-guy committed Mar 20, 2022
1 parent d398d9c commit bd110f4
Show file tree
Hide file tree
Showing 20 changed files with 77 additions and 52 deletions.
2 changes: 1 addition & 1 deletion docs/Defaults.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ <h1 class="page-title">Defaults.js</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 12:41:20 GMT-0700 (Pacific Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 14:36:41 GMT-0700 (Pacific Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/GeneratorLogger.html
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 12:41:20 GMT-0700 (Pacific Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 14:36:41 GMT-0700 (Pacific Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/GeneratorLogger.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ <h1 class="page-title">GeneratorLogger.js</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 12:41:20 GMT-0700 (Pacific Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 14:36:41 GMT-0700 (Pacific Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
10 changes: 5 additions & 5 deletions docs/Loggers.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ <h4 class="name" id=".defaultLevels"><span class="type-signature">(static) </spa

<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#line2438">line 2438</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line2436">line 2436</a>
</li></ul></dd>


Expand Down Expand Up @@ -364,7 +364,7 @@ <h4 class="name" id=".defaultMetaKeys"><span class="type-signature">(static) </s

<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#line2429">line 2429</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line2427">line 2427</a>
</li></ul></dd>


Expand Down Expand Up @@ -1335,7 +1335,7 @@ <h4 class="name" id="default"><span class="type-signature"></span>default<span c

<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#line2380">line 2380</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line2378">line 2378</a>
</li></ul></dd>


Expand Down Expand Up @@ -1951,7 +1951,7 @@ <h4 class="name" id="log"><span class="type-signature"></span>log<span class="si

<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#line2401">line 2401</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line2399">line 2399</a>
</li></ul></dd>


Expand Down Expand Up @@ -3268,7 +3268,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 12:41:20 GMT-0700 (Pacific Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 14:36:41 GMT-0700 (Pacific Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/MySqlLogger.html
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 12:41:20 GMT-0700 (Pacific Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 14:36:41 GMT-0700 (Pacific Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/MySqlLogger.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ <h1 class="page-title">MySqlLogger.js</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 12:41:20 GMT-0700 (Pacific Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 14:36:41 GMT-0700 (Pacific Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/RequestLogger.html
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 12:41:20 GMT-0700 (Pacific Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 14:36:41 GMT-0700 (Pacific Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/RequestLogger.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ <h1 class="page-title">RequestLogger.js</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 12:41:20 GMT-0700 (Pacific Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 14:36:41 GMT-0700 (Pacific Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/Stack.html
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 12:41:20 GMT-0700 (Pacific Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 14:36:41 GMT-0700 (Pacific Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/Stack.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ <h1 class="page-title">Stack.js</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 12:41:20 GMT-0700 (Pacific Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 14:36:41 GMT-0700 (Pacific Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/TaskLogger.html
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 12:41:20 GMT-0700 (Pacific Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 14:36:41 GMT-0700 (Pacific Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/TaskLogger.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ <h1 class="page-title">TaskLogger.js</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 12:41:20 GMT-0700 (Pacific Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 14:36:41 GMT-0700 (Pacific Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ <h3>Deployment</h3>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 12:41:20 GMT-0700 (Pacific Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 14:36:41 GMT-0700 (Pacific Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
24 changes: 11 additions & 13 deletions docs/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ <h1 class="page-title">index.js</h1>
level: onOffDefaultLevelEnum,
colors: Joi.boolean().description('If true, outputs text with ANSI colors to the console').default(true),
data: Joi.boolean().description('If true, sends data, error objects, stack traces, etc. to the console'),
errors: Joi.boolean().default(true).description('If true, logs embedded errors'),
childErrors: Joi.boolean().default(true).description('If true, logs child error objects'),
});

// File settings
Expand Down Expand Up @@ -973,7 +973,7 @@ <h1 class="page-title">index.js</h1>
*/
createConsoleTransport(level, handleExceptions, settings) {
if (!settings) settings = this.options.console;
const { colors, data, errors } = settings;
const { colors, data, childErrors } = settings;

if (data) {
// Fancy console
Expand Down Expand Up @@ -1001,7 +1001,7 @@ <h1 class="page-title">index.js</h1>

// Plain console
const checkTags = winston.format((info) => {
if (!errors &amp;&amp; info.depth) return false;
if (!childErrors &amp;&amp; info.depth > 1) return false;
return this.checkTags('console', info);
})();

Expand Down Expand Up @@ -1112,9 +1112,9 @@ <h1 class="page-title">index.js</h1>
// InvalidParameterException is thrown when the formatter provided to
// winston-cloudwatch returns false
// eslint-disable-next-line no-underscore-dangle
if (error.__type !== 'InvalidParameterException') {
this.log(error, undefined, undefined, logCategories.cloudWatch);
}
if (error.__type === 'InvalidParameterException') return;

this.log(error, undefined, undefined, logCategories.cloudWatch);
}

/**
Expand Down Expand Up @@ -2307,7 +2307,7 @@ <h1 class="page-title">index.js</h1>
}
}

let firstError = '';
let firstError;

const { data } = entry;
if (data) {
Expand Down Expand Up @@ -2336,10 +2336,9 @@ <h1 class="page-title">index.js</h1>
delete context[key];
}

delete data[key];

// Prefer 'error'
if (!firstError || key === 'error') firstError = data[key];
delete data[key];
}
}

Expand Down Expand Up @@ -2375,13 +2374,12 @@ <h1 class="page-title">index.js</h1>
}

const skip = noMessage &amp;&amp; !(data &amp;&amp; Loggers.hasKeys(data));

++depth;
if (!skip || depth) ++depth;

if (!skip) {
// ========================================================================================
// If the entry's message is empty, use data.error or the message of another provided error
if (noMessage) entry.message = firstError;
if (noMessage &amp;&amp; firstError) entry.message = firstError.toString();

// ==========================
// Set groupId and depth meta
Expand Down Expand Up @@ -2712,7 +2710,7 @@ <h1 class="page-title">index.js</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 12:41:20 GMT-0700 (Pacific Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 14:36:41 GMT-0700 (Pacific Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
6 changes: 4 additions & 2 deletions docs/tutorial-Releases.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ <h1 class="page-title">Releases</h1>

<article>
<h1>@goodware/log Release History</h1>
<h2>4.0.0 2022-03-19</h2>
<h2>4.0.0 - 4.0.1 2022-03-20</h2>
<h3>Breaking Changes</h3>
<p>This version might not work in NodeJS versions &lt; 12 (lts/erbium)!</p>
<h3>Changes</h3>
<ul>
<li>Upgrade to winston-cloudwatch v4</li>
<li>Replace aws-sdk with @asw-sdk-client/cloudwatch-logs as a dependency required by winston-cloudwatch</li>
Expand Down Expand Up @@ -252,7 +254,7 @@ <h2>1.3.3 2021-03-22</h2>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 12:41:20 GMT-0700 (Pacific Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Mar 20 2022 14:36:41 GMT-0700 (Pacific Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
22 changes: 10 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ class Loggers {
level: onOffDefaultLevelEnum,
colors: Joi.boolean().description('If true, outputs text with ANSI colors to the console').default(true),
data: Joi.boolean().description('If true, sends data, error objects, stack traces, etc. to the console'),
errors: Joi.boolean().default(true).description('If true, logs embedded errors'),
childErrors: Joi.boolean().default(true).description('If true, logs child error objects'),
});

// File settings
Expand Down Expand Up @@ -932,7 +932,7 @@ ${directories.join('\n')} [warn ${myName}]`);
*/
createConsoleTransport(level, handleExceptions, settings) {
if (!settings) settings = this.options.console;
const { colors, data, errors } = settings;
const { colors, data, childErrors } = settings;

if (data) {
// Fancy console
Expand Down Expand Up @@ -960,7 +960,7 @@ ${directories.join('\n')} [warn ${myName}]`);

// Plain console
const checkTags = winston.format((info) => {
if (!errors && info.depth) return false;
if (!childErrors && info.depth > 1) return false;
return this.checkTags('console', info);
})();

Expand Down Expand Up @@ -1071,9 +1071,9 @@ ${error}`);
// InvalidParameterException is thrown when the formatter provided to
// winston-cloudwatch returns false
// eslint-disable-next-line no-underscore-dangle
if (error.__type !== 'InvalidParameterException') {
this.log(error, undefined, undefined, logCategories.cloudWatch);
}
if (error.__type === 'InvalidParameterException') return;

this.log(error, undefined, undefined, logCategories.cloudWatch);
}

/**
Expand Down Expand Up @@ -2266,7 +2266,7 @@ ${stack}`);
}
}

let firstError = '';
let firstError;

const { data } = entry;
if (data) {
Expand Down Expand Up @@ -2295,10 +2295,9 @@ ${stack}`);
delete context[key];
}

delete data[key];

// Prefer 'error'
if (!firstError || key === 'error') firstError = data[key];
delete data[key];
}
}

Expand Down Expand Up @@ -2334,13 +2333,12 @@ ${stack}`);
}

const skip = noMessage && !(data && Loggers.hasKeys(data));

++depth;
if (!skip || depth) ++depth;

if (!skip) {
// ========================================================================================
// If the entry's message is empty, use data.error or the message of another provided error
if (noMessage) entry.message = firstError;
if (noMessage && firstError) entry.message = firstError.toString();

// ==========================
// Set groupId and depth meta
Expand Down
6 changes: 5 additions & 1 deletion moredocs/Releases.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# @goodware/log Release History

## 4.0.0 2022-03-19
## 4.0.0 - 4.0.1 2022-03-20

### Breaking Changes

This version might not work in NodeJS versions < 12 (lts/erbium)!

### Changes

- Upgrade to winston-cloudwatch v4
- Replace aws-sdk with @asw-sdk-client/cloudwatch-logs as a dependency required by winston-cloudwatch
- Replace nano with ulid
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@goodware/log",
"version": "4.0.0",
"version": "4.0.1",
"description": "Batteries-included Winston3-based loggger with console, file, and AWS CloudWatch Logs transports",
"scripts": {
"docs": "rm -rf docs ; node_modules/.bin/jsdoc --configure .jsdoc.json --verbose -R README.md *.js",
Expand Down
10 changes: 9 additions & 1 deletion tests/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ let config = {
data: true,
},
cloudWatch: {
// region: 'us-west-2', // set AWS_DEFAULT_REGION environment variable
// To test CloudWatch Logs, set AWS_DEFAULT_REGION environment variable
// region: 'us-west-2',
logGroup: `/${env}/goodware/log`,
},
categories: {
Expand All @@ -28,6 +29,13 @@ let config = {
data: false,
},
},
briefConsoleNoErrors: {
console: {
level: 'info',
data: false,
childErrors: false,
},
},
dataConsole: {
console: {
level: 'info',
Expand Down

0 comments on commit bd110f4

Please sign in to comment.