You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<li>Defined in <ahref="https://github.com/fullstack-build/tslog/blob/8d1557f/src/interfaces.ts#L303">interfaces.ts:303</a></li>
225
+
<li>Defined in <ahref="https://github.com/fullstack-build/tslog/blob/0925709/src/interfaces.ts#L303">interfaces.ts:303</a></li>
226
226
</ul>
227
227
</aside>
228
228
<divclass="tsd-comment tsd-typography">
@@ -237,7 +237,7 @@ <h3>With<wbr>Millisecond</h3>
237
237
<divclass="tsd-signature tsd-kind-icon">With<wbr>Millisecond<T><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">T</span><spanclass="tsd-signature-symbol"> & </span><spanclass="tsd-signature-type">"millisecond"</span></div>
238
238
<asideclass="tsd-sources">
239
239
<ul>
240
-
<li>Defined in <ahref="https://github.com/fullstack-build/tslog/blob/8d1557f/src/interfaces.ts#L383">interfaces.ts:383</a></li>
240
+
<li>Defined in <ahref="https://github.com/fullstack-build/tslog/blob/0925709/src/interfaces.ts#L383">interfaces.ts:383</a></li>
<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>
312
313
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.
313
314
Instead of parsing a <em>pretty</em> output, most log services prefer a <em>JSON</em> representation. </p>
When debugging it can get quite handy to be able to group all logs based by a unique identifier <code>requestId</code>. </p>
363
364
<p>A <code>requestId</code> can either be a <code>string</code> or a function.<br>
364
365
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 <ahref="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 >= 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 <ahref="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 >= 14.<br>
368
+
However it is still marked as <em>experimental</em>. <br>
368
369
Here is <ahref="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>
369
370
<blockquote>
370
-
<p><em>Hint</em>: If you prefer to use a more proven (yet slower) approach, you may want to check out <ahref="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 <ahref="https://www.npmjs.com/package/cls-hooked" target="_blank"><code>cls-hooked</code></a>.</p>
371
372
</blockquote>
372
373
<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>
373
374
<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