Skip to content

Commit 69eb88c

Browse files
committed
Save log status into localstorage
1 parent a8de996 commit 69eb88c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/common/logger.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
* https://opensource.org/licenses/MIT
66
*/
77

8-
let OPEN_LOG = false
8+
const STORAGE_KEY = "_logOpen"
9+
const STORAGE_VAL = "1"
10+
11+
let OPEN_LOG = localStorage.getItem(STORAGE_KEY) === STORAGE_VAL
912

1013
/**
1114
* @since 0.0.4
@@ -20,6 +23,7 @@ export function log(...args: any) {
2023
*/
2124
export function openLog(): string {
2225
OPEN_LOG = true
26+
localStorage.setItem(STORAGE_KEY, STORAGE_VAL)
2327
return 'Opened the log manually.'
2428
}
2529

@@ -28,5 +32,6 @@ export function openLog(): string {
2832
*/
2933
export function closeLog(): string {
3034
OPEN_LOG = false
35+
localStorage.removeItem(STORAGE_KEY)
3136
return 'Closed the log manually.'
3237
}

0 commit comments

Comments
 (0)