Skip to content

Commit b0e2cd1

Browse files
committed
Fixed wrong number for all
1 parent a18bd22 commit b0e2cd1

2 files changed

Lines changed: 17 additions & 15 deletions

File tree

examples/log/index.html

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -202,22 +202,22 @@ <h2>
202202
</a>
203203
</h2>
204204
<p>
205-
You can fine-tune which messages you want shown by adding together the corresponding numbers for each level:
205+
The module uses <a href="https://en.wikipedia.org/wiki/Mask_(computing)">bitmask</a> to filter which types
206+
of messages that will be shown. It assigns the following 10-based number to each type (binaries in
207+
parenthesis):
206208
</p>
207209
<ul>
208-
<li>Error: 1</li>
209-
<li>Warning: 2</li>
210-
<li>Message: 4</li>
211-
<li>Success: 8</li>
212-
<li>Info: 16</li>
213-
<li>Debug: 32</li>
210+
<li>Error: 1 (000001)</li>
211+
<li>Warning: 2 (000010)</li>
212+
<li>Message: 4 (000100)</li>
213+
<li>Success: 8 (001000)</li>
214+
<li>Info: 16 (010000)</li>
215+
<li>Debug: 32 (100000)</li>
214216
</ul>
215-
<p>
216-
Setting level to 64 will show all messages.
217-
</p>
218217
<p>
219218
By default only error, warning, and normal messages will be shown, hence the number 7 that is shown by default
220-
in this example.
219+
in this example. You can set it to show all types of messages by passing 63 (which is the sum of all, and is
220+
111111 in binary).
221221
</p>
222222
<script id="script-log-setLevel">
223223
window.addEventListener('DOMContentLoaded', () => {

src/log.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,19 @@ export function clear (): void {
129129
}
130130

131131
/**
132-
* Lets you configure which types of messages will be shown. The number is a
133-
* sum of the levels you want to show:
132+
* Lets you configure which types of messages will be shown. The module uses
133+
* [bitmask](https://en.wikipedia.org/wiki/Mask_(computing)) to filter which
134+
* types of messages should be shown. E.g. if you only want warning messages
135+
* to be shown, pass 2 to the function, if you want warning and success to be
136+
* shown, pass 10 (2+8). By passing the sum of all, 63, you'll show all
137+
* types of messages.
134138
*
135139
* - Error: 1
136140
* - Warning: 2
137141
* - Message: 4
138142
* - Success: 8
139143
* - Info: 16
140144
* - Debug: 32
141-
*
142-
* You can also choose to set all by passing the number *64*.
143145
*/
144146
export function setLevel (level: number): void {
145147
_level = TALL

0 commit comments

Comments
 (0)