-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: logger is enabled if dev and debug mode
- Loading branch information
Showing
11 changed files
with
67 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// contentScript does not loggin in production by default | ||
const canLog = () => { | ||
// localStorage.setItem("DEBUG", "@textlint/editor"); | ||
const enabledDebugStorage = | ||
typeof window !== "undefined" && | ||
typeof window.localStorage !== "undefined" && | ||
(window.localStorage.getItem("DEBUG")?.includes("@textlint") || window.localStorage.getItem("DEBUG") === "*"); | ||
// ?debug_textlint | ||
const enabledDebugLocation = | ||
typeof window !== "undefined" && | ||
typeof window.location !== "undefined" && | ||
new URL(window.location.href).searchParams.has("debug_textlint"); | ||
|
||
return process.env.NODE_ENV === "development" || enabledDebugLocation || enabledDebugStorage; | ||
}; | ||
export const logger = { | ||
log(...args: any[]) { | ||
if (!canLog()) { | ||
return; | ||
} | ||
console.log("[@textlint/editor]", ...args); | ||
}, | ||
error(...args: any[]) { | ||
if (!canLog()) { | ||
return; | ||
} | ||
console.error("[@textlint/editor]", ...args); | ||
} | ||
}; |