Skip to content
This repository was archived by the owner on Aug 24, 2025. It is now read-only.

Commit 85309d9

Browse files
committed
Replaced loglevel
1 parent 503036c commit 85309d9

File tree

6 files changed

+27
-30
lines changed

6 files changed

+27
-30
lines changed

package-lock.json

Lines changed: 0 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
"html2canvas": "^1.4.1",
3232
"lightdash": "^14.0.0",
3333
"lodash-es": "^4.17.21",
34-
"loglevel": "^1.8.0",
3534
"pako": "^2.0.4",
3635
"pinia": "^2.0.23",
3736
"tippy.js": "^6.3.7",

src/application/bridge.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
import { cardDatabase } from "@/application/ctx";
2+
import { useDataStore } from "@/application/store/data";
3+
import { useDeckStore } from "@/application/store/deck";
14
import type { Card, Deck, ImportResult } from "@/core/lib";
25
import { DeckPart, FindCardBy, getLogger } from "@/core/lib";
6+
import { getExistingElseThrow } from "lightdash";
37
import type {
48
ApplicationApi,
59
ApplicationEvent,
@@ -8,10 +12,6 @@ import type {
812
ExternalDeck,
913
SlimExternalCard,
1014
} from "./api";
11-
import { useDataStore } from "@/application/store/data";
12-
import { useDeckStore } from "@/application/store/deck";
13-
import { getExistingElseThrow } from "lightdash";
14-
import { cardDatabase } from "@/application/ctx";
1515

1616
const logger = getLogger("bridge");
1717

@@ -81,12 +81,12 @@ class EventEmitter<TEvent> {
8181
}
8282

8383
on(event: TEvent, callback: () => void): void {
84-
this.#logger.trace(`Registering '${event}' event.`);
84+
this.#logger.debug(`Registering '${event}' event.`);
8585
getExistingElseThrow(this.#eventCallbacks, event).push(callback);
8686
}
8787

8888
emit(event: TEvent): void {
89-
this.#logger.trace(`Emitting '${event}' event.`);
89+
this.#logger.debug(`Emitting '${event}' event.`);
9090
getExistingElseThrow(this.#eventCallbacks, event).forEach((callback) =>
9191
callback(),
9292
);

src/core/logger.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
1-
import type { Logger } from "loglevel";
2-
import { getLogger as getLoglevelLogger, levels } from "loglevel";
3-
import { DEBUG } from "./mode";
41
import { name as getName } from "lightdash";
52

3+
interface Logger {
4+
error: typeof console.error;
5+
warn: typeof console.warn;
6+
info: typeof console.info;
7+
debug: typeof console.debug;
8+
}
9+
10+
const DEBUG = import.meta.env.MODE === "development";
11+
612
export const getLogger = (consumer: unknown): Logger => {
713
const name = getName(consumer);
814
if (name == null) {
915
throw new TypeError(
1016
`Cannot find name for consumer: '${String(consumer)}'`,
1117
);
1218
}
13-
const logger = getLoglevelLogger(name);
14-
logger.setLevel(DEBUG ? levels.DEBUG : levels.WARN);
15-
return logger;
19+
return {
20+
error: (...args) => console.error(name, ...args),
21+
warn: (...args) => console.warn(name, ...args),
22+
info: (...args) => console.info(name, ...args),
23+
debug: (...args) => {
24+
if (DEBUG) {
25+
console.debug(name, ...args);
26+
}
27+
},
28+
};
1629
};

src/core/mode.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/tooltip/tooltip/bindTooltip.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ const showTooltip = (
2222
target: HTMLElement | HTMLAnchorElement,
2323
cardKey: string,
2424
): void => {
25-
logger.trace(`Attempting to show tooltip for '${cardKey}'.`);
25+
logger.debug(`Attempting to show tooltip for '${cardKey}'.`);
2626
tooltipController
2727
.loadCard(cardKey)
2828
.then((card) => {
29-
logger.trace("Loaded card.", card);
29+
logger.debug("Loaded card.", card);
3030
instance.setContent(createTooltipElement(card));
3131

3232
if (target instanceof HTMLAnchorElement) {

0 commit comments

Comments
 (0)