Skip to content

Commit

Permalink
Remove dependency chalk, use native util.inspect colors
Browse files Browse the repository at this point in the history
  • Loading branch information
terehov committed May 24, 2020
1 parent 3fd89ce commit a939ccd
Show file tree
Hide file tree
Showing 24 changed files with 248 additions and 495 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Supported log levels are:
`0: silly`, `1: trace`, `2: debug`, `3: info`, `4: warn`, `5: error`, `6: fatal`

Per default log level 0 - 3 are written to `stdout` and 4 - 6 are written to `stderr`.
Each log level is printed in a different color, that is completely customizable through the settings object.
Each log level is printed in a different color, that is customizable through the settings object.

> **Hint:** Log level `trace` behaves a bit differently compared to all the other log levels.
> While it is possible to activate a stack trace for every log level, it is already activated for `trace` by default.
Expand Down Expand Up @@ -282,6 +282,11 @@ _There is no `console.fatal`._
##### `logLevelsColors`

This setting allows you to overwrite the default log level colors of `tslog`.

Possible styles are:
* <a href="https://nodejs.org/api/util.html#util_foreground_colors" target="_blank">Foreground colors</a>
* <a href="https://nodejs.org/api/util.html#util_background_colors" target="_blank">Background colors</a>
* <a href="https://nodejs.org/api/util.html#util_modifiers" target="_blank">Modifiers</a>

##### `prettyInspectHighlightStyles`
This setting allows you to overwrite the default colors of `tslog` used for the native Node.js `utils.inspect` interpolation.
Expand Down
2 changes: 1 addition & 1 deletion docs/api_extractor/tslog.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export class Logger {

// @public
export type TLogLevelColor = {
[key in TLogLevelId]: string;
[key in TLogLevelId]: TUtilsInspectColors;
};

// @public
Expand Down
2 changes: 1 addition & 1 deletion docs/tsdoc/assets/js/search.json

Large diffs are not rendered by default.

23 changes: 10 additions & 13 deletions docs/tsdoc/classes/logger.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ <h3>constructor</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/9418f63/src/index.ts#L65">index.ts:65</a></li>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/3fd89ce/src/index.ts#L65">index.ts:65</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -150,7 +150,7 @@ <h3><span class="tsd-flag ts-flagReadonly">Readonly</span> settings</h3>
<div class="tsd-signature tsd-kind-icon">settings<span class="tsd-signature-symbol">:</span> <a href="../interfaces/isettings.html" class="tsd-signature-type">ISettings</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/9418f63/src/index.ts#L65">index.ts:65</a></li>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/3fd89ce/src/index.ts#L65">index.ts:65</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -172,7 +172,7 @@ <h3>attach<wbr>Transport</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/9418f63/src/index.ts#L142">index.ts:142</a></li>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/3fd89ce/src/index.ts#L142">index.ts:142</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -209,7 +209,7 @@ <h3>debug</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/9418f63/src/index.ts#L172">index.ts:172</a></li>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/3fd89ce/src/index.ts#L172">index.ts:172</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -240,7 +240,7 @@ <h3>error</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/9418f63/src/index.ts#L196">index.ts:196</a></li>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/3fd89ce/src/index.ts#L196">index.ts:196</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -271,7 +271,7 @@ <h3>fatal</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/9418f63/src/index.ts#L204">index.ts:204</a></li>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/3fd89ce/src/index.ts#L204">index.ts:204</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -302,7 +302,7 @@ <h3>info</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/9418f63/src/index.ts#L180">index.ts:180</a></li>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/3fd89ce/src/index.ts#L180">index.ts:180</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -333,7 +333,7 @@ <h3>silly</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/9418f63/src/index.ts#L156">index.ts:156</a></li>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/3fd89ce/src/index.ts#L156">index.ts:156</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -364,7 +364,7 @@ <h3>trace</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/9418f63/src/index.ts#L164">index.ts:164</a></li>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/3fd89ce/src/index.ts#L164">index.ts:164</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -395,7 +395,7 @@ <h3>warn</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/9418f63/src/index.ts#L188">index.ts:188</a></li>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/3fd89ce/src/index.ts#L188">index.ts:188</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -476,9 +476,6 @@ <h4 class="tsd-returns-title">Returns <a href="../interfaces/ilogobject.html" cl
<li class=" tsd-kind-interface">
<a href="../interfaces/ihighlightstyles.html" class="tsd-kind-icon">IHighlight<wbr>Styles</a>
</li>
<li class=" tsd-kind-interface">
<a href="../interfaces/ijsonhighlightcolorschalk.html" class="tsd-kind-icon">IJson<wbr>Highlight<wbr>Colors<wbr>Chalk</a>
</li>
<li class=" tsd-kind-interface">
<a href="../interfaces/iloglevel.html" class="tsd-kind-icon">ILog<wbr>Level</a>
</li>
Expand Down
14 changes: 5 additions & 9 deletions docs/tsdoc/globals.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ <h3>Interfaces</h3>
<li class="tsd-kind-interface"><a href="interfaces/icodeframe.html" class="tsd-kind-icon">ICode<wbr>Frame</a></li>
<li class="tsd-kind-interface"><a href="interfaces/ierrorobject.html" class="tsd-kind-icon">IError<wbr>Object</a></li>
<li class="tsd-kind-interface"><a href="interfaces/ihighlightstyles.html" class="tsd-kind-icon">IHighlight<wbr>Styles</a></li>
<li class="tsd-kind-interface"><a href="interfaces/ijsonhighlightcolorschalk.html" class="tsd-kind-icon">IJson<wbr>Highlight<wbr>Colors<wbr>Chalk</a></li>
<li class="tsd-kind-interface"><a href="interfaces/iloglevel.html" class="tsd-kind-icon">ILog<wbr>Level</a></li>
<li class="tsd-kind-interface"><a href="interfaces/ilogobject.html" class="tsd-kind-icon">ILog<wbr>Object</a></li>
<li class="tsd-kind-interface"><a href="interfaces/ilogobjectstringifiable.html" class="tsd-kind-icon">ILog<wbr>Object<wbr>Stringifiable</a></li>
Expand Down Expand Up @@ -107,7 +106,7 @@ <h3>TLog<wbr>Level<wbr>Color</h3>
<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>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/9418f63/src/interfaces.ts#L34">interfaces.ts:34</a></li>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/3fd89ce/src/interfaces.ts#L33">interfaces.ts:33</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -127,7 +126,7 @@ <h3>TLog<wbr>Level<wbr>Id</h3>
<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>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/9418f63/src/interfaces.ts#L22">interfaces.ts:22</a></li>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/3fd89ce/src/interfaces.ts#L21">interfaces.ts:21</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -142,7 +141,7 @@ <h3>TLog<wbr>Level<wbr>Name</h3>
<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>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/9418f63/src/interfaces.ts#L28">interfaces.ts:28</a></li>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/3fd89ce/src/interfaces.ts#L27">interfaces.ts:27</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -157,7 +156,7 @@ <h3>TTransport<wbr>Logger</h3>
<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>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/9418f63/src/interfaces.ts#L204">interfaces.ts:204</a></li>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/3fd89ce/src/interfaces.ts#L203">interfaces.ts:203</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -183,7 +182,7 @@ <h3>TUtils<wbr>Inspect<wbr>Colors</h3>
<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">"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>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/9418f63/src/interfaces.ts#L217">interfaces.ts:217</a></li>
<li>Defined in <a href="https://github.com/fullstack-build/tslog/blob/3fd89ce/src/interfaces.ts#L216">interfaces.ts:216</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -216,9 +215,6 @@ <h3>TUtils<wbr>Inspect<wbr>Colors</h3>
<li class=" tsd-kind-interface">
<a href="interfaces/ihighlightstyles.html" class="tsd-kind-icon">IHighlight<wbr>Styles</a>
</li>
<li class=" tsd-kind-interface">
<a href="interfaces/ijsonhighlightcolorschalk.html" class="tsd-kind-icon">IJson<wbr>Highlight<wbr>Colors<wbr>Chalk</a>
</li>
<li class=" tsd-kind-interface">
<a href="interfaces/iloglevel.html" class="tsd-kind-icon">ILog<wbr>Level</a>
</li>
Expand Down
11 changes: 7 additions & 4 deletions docs/tsdoc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ <h4>Log level</h4>
Supported log levels are: </p>
<p><code>0: silly</code>, <code>1: trace</code>, <code>2: debug</code>, <code>3: info</code>, <code>4: warn</code>, <code>5: error</code>, <code>6: fatal</code></p>
<p>Per default log level 0 - 3 are written to <code>stdout</code> and 4 - 6 are written to <code>stderr</code>.
Each log level is printed in a different color, that is completely customizable through the settings object.</p>
Each log level is printed in a different color, that is customizable through the settings object.</p>
<blockquote>
<p><strong>Hint:</strong> Log level <code>trace</code> behaves a bit differently compared to all the other log levels.
While it is possible to activate a stack trace for every log level, it is already activated for <code>trace</code> by default.
Expand Down Expand Up @@ -302,6 +302,12 @@ <h5><code>overwriteConsole</code></h5>
<h5><code>logLevelsColors</code></h5>
</a>
<p>This setting allows you to overwrite the default log level colors of <code>tslog</code>.</p>
<p>Possible styles are: </p>
<ul>
<li><a href="https://nodejs.org/api/util.html#util_foreground_colors" target="_blank">Foreground colors</a></li>
<li><a href="https://nodejs.org/api/util.html#util_background_colors" target="_blank">Background colors</a></li>
<li><a href="https://nodejs.org/api/util.html#util_modifiers" target="_blank">Modifiers</a></li>
</ul>
<a href="#prettyinspecthighlightstyles" id="prettyinspecthighlightstyles" style="color: inherit; text-decoration: none;">
<h5><code>prettyInspectHighlightStyles</code></h5>
</a>
Expand Down Expand Up @@ -414,9 +420,6 @@ <h5>Storing logs in a file</h5>
<li class=" tsd-kind-interface">
<a href="interfaces/ihighlightstyles.html" class="tsd-kind-icon">IHighlight<wbr>Styles</a>
</li>
<li class=" tsd-kind-interface">
<a href="interfaces/ijsonhighlightcolorschalk.html" class="tsd-kind-icon">IJson<wbr>Highlight<wbr>Colors<wbr>Chalk</a>
</li>
<li class=" tsd-kind-interface">
<a href="interfaces/iloglevel.html" class="tsd-kind-icon">ILog<wbr>Level</a>
</li>
Expand Down
Loading

0 comments on commit a939ccd

Please sign in to comment.