Skip to content

Commit 5442dfb

Browse files
authored
Merge pull request #28 from fullstack-build/development
Development: Add new type:hidden
2 parents 315d2a4 + 18aa5c7 commit 5442dfb

24 files changed

+250
-216
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,12 @@ All possible settings are defined in the `ISettingsParam` interface and modern I
272272
##### `type`
273273
```default: "pretty"```
274274

275-
You can either pretty print logs, or print them as `json`.<br>
275+
Possible values: `"json" | "pretty" | "hidden"`
276+
277+
You can either `pretty` print logs, print them as `json` or hide them all together with `hidden` (e.g. when using custom transports).<br>
276278
Having `json` as an output format is particularly useful, if you want to forward your logs directly from your `std` to another log service.
277279
Instead of parsing a _pretty_ output, most log services prefer a _JSON_ representation.
280+
278281
> **Hint:** Printing in `json` gives you direct access to all the available information, like _stack trace_ and _code frame_ and so on.
279282
280283
```typescript

docs/api_extractor/tslog.api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export interface ISettings extends ISettingsParam {
172172
// (undocumented)
173173
suppressStdOutput: boolean;
174174
// (undocumented)
175-
type: "json" | "pretty";
175+
type: "json" | "pretty" | "hidden";
176176
}
177177

178178
// @public
@@ -208,7 +208,7 @@ export interface ISettingsParam {
208208
stdErr?: IStd;
209209
stdOut?: IStd;
210210
suppressStdOutput?: boolean;
211-
type?: "json" | "pretty";
211+
type?: "json" | "pretty" | "hidden";
212212
}
213213

214214
// @public

docs/tsdoc/classes/logger.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ <h3>constructor</h3>
124124
<li class="tsd-description">
125125
<aside class="tsd-sources">
126126
<ul>
127-
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/8d1557f/src/index.ts#L76">index.ts:76</a></li>
127+
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/0925709/src/index.ts#L76">index.ts:76</a></li>
128128
</ul>
129129
</aside>
130130
<div class="tsd-comment tsd-typography">
@@ -160,7 +160,7 @@ <h3>settings</h3>
160160
<li class="tsd-description">
161161
<aside class="tsd-sources">
162162
<ul>
163-
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/8d1557f/src/index.ts#L158">index.ts:158</a></li>
163+
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/0925709/src/index.ts#L158">index.ts:158</a></li>
164164
</ul>
165165
</aside>
166166
<div class="tsd-comment tsd-typography">
@@ -185,7 +185,7 @@ <h3>attach<wbr>Transport</h3>
185185
<li class="tsd-description">
186186
<aside class="tsd-sources">
187187
<ul>
188-
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/8d1557f/src/index.ts#L249">index.ts:249</a></li>
188+
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/0925709/src/index.ts#L249">index.ts:249</a></li>
189189
</ul>
190190
</aside>
191191
<div class="tsd-comment tsd-typography">
@@ -222,7 +222,7 @@ <h3>debug</h3>
222222
<li class="tsd-description">
223223
<aside class="tsd-sources">
224224
<ul>
225-
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/8d1557f/src/index.ts#L279">index.ts:279</a></li>
225+
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/0925709/src/index.ts#L279">index.ts:279</a></li>
226226
</ul>
227227
</aside>
228228
<div class="tsd-comment tsd-typography">
@@ -253,7 +253,7 @@ <h3>error</h3>
253253
<li class="tsd-description">
254254
<aside class="tsd-sources">
255255
<ul>
256-
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/8d1557f/src/index.ts#L303">index.ts:303</a></li>
256+
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/0925709/src/index.ts#L303">index.ts:303</a></li>
257257
</ul>
258258
</aside>
259259
<div class="tsd-comment tsd-typography">
@@ -284,7 +284,7 @@ <h3>fatal</h3>
284284
<li class="tsd-description">
285285
<aside class="tsd-sources">
286286
<ul>
287-
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/8d1557f/src/index.ts#L311">index.ts:311</a></li>
287+
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/0925709/src/index.ts#L311">index.ts:311</a></li>
288288
</ul>
289289
</aside>
290290
<div class="tsd-comment tsd-typography">
@@ -315,7 +315,7 @@ <h3>get<wbr>Child<wbr>Logger</h3>
315315
<li class="tsd-description">
316316
<aside class="tsd-sources">
317317
<ul>
318-
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/8d1557f/src/index.ts#L234">index.ts:234</a></li>
318+
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/0925709/src/index.ts#L234">index.ts:234</a></li>
319319
</ul>
320320
</aside>
321321
<div class="tsd-comment tsd-typography">
@@ -346,7 +346,7 @@ <h3>info</h3>
346346
<li class="tsd-description">
347347
<aside class="tsd-sources">
348348
<ul>
349-
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/8d1557f/src/index.ts#L287">index.ts:287</a></li>
349+
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/0925709/src/index.ts#L287">index.ts:287</a></li>
350350
</ul>
351351
</aside>
352352
<div class="tsd-comment tsd-typography">
@@ -377,7 +377,7 @@ <h3>pretty<wbr>Error</h3>
377377
<li class="tsd-description">
378378
<aside class="tsd-sources">
379379
<ul>
380-
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/8d1557f/src/index.ts#L325">index.ts:325</a></li>
380+
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/0925709/src/index.ts#L325">index.ts:325</a></li>
381381
</ul>
382382
</aside>
383383
<div class="tsd-comment tsd-typography">
@@ -444,7 +444,7 @@ <h3>set<wbr>Settings</h3>
444444
<li class="tsd-description">
445445
<aside class="tsd-sources">
446446
<ul>
447-
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/8d1557f/src/index.ts#L175">index.ts:175</a></li>
447+
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/0925709/src/index.ts#L175">index.ts:175</a></li>
448448
</ul>
449449
</aside>
450450
<div class="tsd-comment tsd-typography">
@@ -482,7 +482,7 @@ <h3>silly</h3>
482482
<li class="tsd-description">
483483
<aside class="tsd-sources">
484484
<ul>
485-
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/8d1557f/src/index.ts#L263">index.ts:263</a></li>
485+
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/0925709/src/index.ts#L263">index.ts:263</a></li>
486486
</ul>
487487
</aside>
488488
<div class="tsd-comment tsd-typography">
@@ -513,7 +513,7 @@ <h3>trace</h3>
513513
<li class="tsd-description">
514514
<aside class="tsd-sources">
515515
<ul>
516-
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/8d1557f/src/index.ts#L271">index.ts:271</a></li>
516+
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/0925709/src/index.ts#L271">index.ts:271</a></li>
517517
</ul>
518518
</aside>
519519
<div class="tsd-comment tsd-typography">
@@ -544,7 +544,7 @@ <h3>warn</h3>
544544
<li class="tsd-description">
545545
<aside class="tsd-sources">
546546
<ul>
547-
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/8d1557f/src/index.ts#L295">index.ts:295</a></li>
547+
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/0925709/src/index.ts#L295">index.ts:295</a></li>
548548
</ul>
549549
</aside>
550550
<div class="tsd-comment tsd-typography">

docs/tsdoc/globals.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ <h3>TLog<wbr>Level<wbr>Color</h3>
116116
<div class="tsd-signature tsd-kind-icon">TLog<wbr>Level<wbr>Color<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{}</span></div>
117117
<aside class="tsd-sources">
118118
<ul>
119-
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/8d1557f/src/interfaces.ts#L34">interfaces.ts:34</a></li>
119+
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/0925709/src/interfaces.ts#L34">interfaces.ts:34</a></li>
120120
</ul>
121121
</aside>
122122
<div class="tsd-comment tsd-typography">
@@ -136,7 +136,7 @@ <h3>TLog<wbr>Level<wbr>Id</h3>
136136
<div class="tsd-signature tsd-kind-icon">TLog<wbr>Level<wbr>Id<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">keyof </span><a href="interfaces/iloglevel.html" class="tsd-signature-type">ILogLevel</a></div>
137137
<aside class="tsd-sources">
138138
<ul>
139-
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/8d1557f/src/interfaces.ts#L22">interfaces.ts:22</a></li>
139+
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/0925709/src/interfaces.ts#L22">interfaces.ts:22</a></li>
140140
</ul>
141141
</aside>
142142
<div class="tsd-comment tsd-typography">
@@ -151,7 +151,7 @@ <h3>TLog<wbr>Level<wbr>Name</h3>
151151
<div class="tsd-signature tsd-kind-icon">TLog<wbr>Level<wbr>Name<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">ILogLevel</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">TLogLevelId</span><span class="tsd-signature-symbol">]</span></div>
152152
<aside class="tsd-sources">
153153
<ul>
154-
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/8d1557f/src/interfaces.ts#L28">interfaces.ts:28</a></li>
154+
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/0925709/src/interfaces.ts#L28">interfaces.ts:28</a></li>
155155
</ul>
156156
</aside>
157157
<div class="tsd-comment tsd-typography">
@@ -166,7 +166,7 @@ <h3>TRequest<wbr>IdFunction</h3>
166166
<div class="tsd-signature tsd-kind-icon">TRequest<wbr>IdFunction<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">string</span></div>
167167
<aside class="tsd-sources">
168168
<ul>
169-
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/8d1557f/src/interfaces.ts#L42">interfaces.ts:42</a></li>
169+
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/0925709/src/interfaces.ts#L42">interfaces.ts:42</a></li>
170170
</ul>
171171
</aside>
172172
<div class="tsd-comment tsd-typography">
@@ -196,7 +196,7 @@ <h3>TTransport<wbr>Logger</h3>
196196
<div class="tsd-signature tsd-kind-icon">TTransport<wbr>Logger&lt;T&gt;<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{}</span></div>
197197
<aside class="tsd-sources">
198198
<ul>
199-
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/8d1557f/src/interfaces.ts#L290">interfaces.ts:290</a></li>
199+
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/0925709/src/interfaces.ts#L290">interfaces.ts:290</a></li>
200200
</ul>
201201
</aside>
202202
<div class="tsd-comment tsd-typography">
@@ -222,7 +222,7 @@ <h3>TUtils<wbr>Inspect<wbr>Colors</h3>
222222
<div class="tsd-signature tsd-kind-icon">TUtils<wbr>Inspect<wbr>Colors<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">"reset"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"bold"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"dim"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"italic"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"underline"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"blink"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"inverse"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"hidden"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"strikethrough"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"doubleunderline"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"black"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"red"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"green"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"yellow"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"blue"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"magenta"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"cyan"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"white"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"bgBlack"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"bgRed"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"bgGreen"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"bgYellow"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"bgBlue"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"bgMagenta"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"bgCyan"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"bgWhite"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"framed"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"overlined"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"gray"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"grey"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"redBright"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"greenBright"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"yellowBright"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"blueBright"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"magentaBright"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"cyanBright"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"whiteBright"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"bgGray"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"bgRedBright"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"bgGreenBright"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"bgYellowBright"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"bgBlueBright"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"bgMagentaBright"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"bgCyanBright"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"bgWhiteBright"</span></div>
223223
<aside class="tsd-sources">
224224
<ul>
225-
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/8d1557f/src/interfaces.ts#L303">interfaces.ts:303</a></li>
225+
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/0925709/src/interfaces.ts#L303">interfaces.ts:303</a></li>
226226
</ul>
227227
</aside>
228228
<div class="tsd-comment tsd-typography">
@@ -237,7 +237,7 @@ <h3>With<wbr>Millisecond</h3>
237237
<div class="tsd-signature tsd-kind-icon">With<wbr>Millisecond&lt;T&gt;<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">T</span><span class="tsd-signature-symbol"> &amp; </span><span class="tsd-signature-type">"millisecond"</span></div>
238238
<aside class="tsd-sources">
239239
<ul>
240-
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/8d1557f/src/interfaces.ts#L383">interfaces.ts:383</a></li>
240+
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/0925709/src/interfaces.ts#L383">interfaces.ts:383</a></li>
241241
</ul>
242242
</aside>
243243
<h4 class="tsd-type-parameters-title">Type parameters</h4>
@@ -256,7 +256,7 @@ <h3>Date<wbr>Time<wbr>Format<wbr>Part<wbr>Types</h3>
256256
<div class="tsd-signature tsd-kind-icon">Date<wbr>Time<wbr>Format<wbr>Part<wbr>Types<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">any</span></div>
257257
<aside class="tsd-sources">
258258
<ul>
259-
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/8d1557f/src/interfaces.ts#L2">interfaces.ts:2</a></li>
259+
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/0925709/src/interfaces.ts#L2">interfaces.ts:2</a></li>
260260
</ul>
261261
</aside>
262262
</section>

docs/tsdoc/index.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ <h4>Settings</h4>
308308
<h5><code>type</code></h5>
309309
</a>
310310
<p><code>default: &quot;pretty&quot;</code></p>
311-
<p>You can either pretty print logs, or print them as <code>json</code>.<br>
311+
<p>Possible values: <code>&quot;json&quot; | &quot;pretty&quot; | &quot;hidden&quot;</code> </p>
312+
<p>You can either <code>pretty</code> print logs, print them as <code>json</code> or hide them all together with <code>hidden</code> (e.g. when using custom transports).<br>
312313
Having <code>json</code> as an output format is particularly useful, if you want to forward your logs directly from your <code>std</code> to another log service.
313314
Instead of parsing a <em>pretty</em> output, most log services prefer a <em>JSON</em> representation. </p>
314315
<blockquote>
@@ -362,12 +363,12 @@ <h5><code>requestId</code></h5>
362363
When debugging it can get quite handy to be able to group all logs based by a unique identifier <code>requestId</code>. </p>
363364
<p>A <code>requestId</code> can either be a <code>string</code> or a function.<br>
364365
A string is suitable when you create a child logger for each request, while a function is helpful, when you need to reuse the same logger and need to obtain a <code>requistId</code> dynamically. </p>
365-
<p>*<em>With Node.js 13.10, we got a new feature called <a href="https://nodejs.org/api/async_hooks.html#async_hooks_class_asynclocalstorage" target="_blank">AsyncLocalStorage.</a> **<br>
366-
It has also been backported to Node.js v12.17.0 and of course it works with Node.js &gt;= 14.<br>
367-
However it is still marked as *experimental</em>. <br>
366+
<p><strong>With Node.js 13.10, we got a new feature called <a href="https://nodejs.org/api/async_hooks.html#async_hooks_class_asynclocalstorage" target="_blank">AsyncLocalStorage.</a></strong><br>
367+
It has also been backported to Node.js v12.17.0 and of course it works with Node.js &gt;= 14.<br>
368+
However it is still marked as <em>experimental</em>. <br>
368369
Here is <a href="https://itnext.io/one-node-js-cls-api-to-rule-them-all-1670ac66a9e8" target="_blank">a blog post by Andrey Pechkurov</a> describing <code>AsyncLocalStorage</code> and performing a small performance comparison. </p>
369370
<blockquote>
370-
<p><em>Hint</em>: If you prefer to use a more proven (yet slower) approach, you may want to check out <a href="https://www.npmjs.com/package/cls-hooked" target="_blank"><code>cls-hooked</code></a>.</p>
371+
<p><strong>Hint</strong>: If you prefer to use a more proven (yet slower) approach, you may want to check out <a href="https://www.npmjs.com/package/cls-hooked" target="_blank"><code>cls-hooked</code></a>.</p>
371372
</blockquote>
372373
<p>Even though <code>tslog</code> is generic enough and works with any of these solutions our example is based on <code>AsyncLocalStorage</code>.<br>
373374
<code>tslog</code> also works with any API framework (like <code>Express</code>, <code>Koa</code>, <code>Hapi</code> and so on), but we are going to use <code>Koa</code> in this example.<br>

0 commit comments

Comments
 (0)