Add control to enable debug logging in production
This commit is contained in:
@@ -5,6 +5,7 @@ import { createAction } from "~/actions";
|
|||||||
import { DeveloperSection } from "~/actions/sections";
|
import { DeveloperSection } from "~/actions/sections";
|
||||||
import env from "~/env";
|
import env from "~/env";
|
||||||
import { client } from "~/utils/ApiClient";
|
import { client } from "~/utils/ApiClient";
|
||||||
|
import Logger from "~/utils/Logger";
|
||||||
import { deleteAllDatabases } from "~/utils/developer";
|
import { deleteAllDatabases } from "~/utils/developer";
|
||||||
|
|
||||||
export const clearIndexedDB = createAction({
|
export const clearIndexedDB = createAction({
|
||||||
@@ -35,16 +36,27 @@ export const createTestUsers = createAction({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const toggleDebugLogging = createAction({
|
||||||
|
name: ({ t }) => t("Toggle debug logging"),
|
||||||
|
icon: <ToolsIcon />,
|
||||||
|
section: DeveloperSection,
|
||||||
|
perform: async ({ t }) => {
|
||||||
|
Logger.debugLoggingEnabled = !Logger.debugLoggingEnabled;
|
||||||
|
stores.toasts.showToast(
|
||||||
|
Logger.debugLoggingEnabled
|
||||||
|
? t("Debug logging enabled")
|
||||||
|
: t("Debug logging disabled")
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export const developer = createAction({
|
export const developer = createAction({
|
||||||
name: ({ t }) => t("Developer"),
|
name: ({ t }) => t("Development"),
|
||||||
keywords: "debug",
|
keywords: "debug",
|
||||||
icon: <ToolsIcon />,
|
icon: <ToolsIcon />,
|
||||||
iconInContextMenu: false,
|
iconInContextMenu: false,
|
||||||
section: DeveloperSection,
|
section: DeveloperSection,
|
||||||
visible: ({ event }) =>
|
children: [clearIndexedDB, toggleDebugLogging, createTestUsers],
|
||||||
env.ENVIRONMENT === "development" ||
|
|
||||||
(event instanceof KeyboardEvent && event.altKey),
|
|
||||||
children: [clearIndexedDB, createTestUsers],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const rootDeveloperActions = [developer];
|
export const rootDeveloperActions = [developer];
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class Logger {
|
|||||||
* @param extra Arbitrary data to be logged
|
* @param extra Arbitrary data to be logged
|
||||||
*/
|
*/
|
||||||
debug(label: LogCategory, message: string, extra?: Extra) {
|
debug(label: LogCategory, message: string, extra?: Extra) {
|
||||||
if (env.ENVIRONMENT === "development") {
|
if (env.ENVIRONMENT === "development" || this.debugLoggingEnabled) {
|
||||||
console.debug(`[${label}] ${message}`, extra);
|
console.debug(`[${label}] ${message}`, extra);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,6 +82,11 @@ class Logger {
|
|||||||
extra,
|
extra,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether additional debug logging is shown in the console or not.
|
||||||
|
*/
|
||||||
|
public debugLoggingEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new Logger();
|
export default new Logger();
|
||||||
|
|||||||
@@ -12,7 +12,10 @@
|
|||||||
"Delete collection": "Delete collection",
|
"Delete collection": "Delete collection",
|
||||||
"Delete IndexedDB cache": "Delete IndexedDB cache",
|
"Delete IndexedDB cache": "Delete IndexedDB cache",
|
||||||
"IndexedDB cache deleted": "IndexedDB cache deleted",
|
"IndexedDB cache deleted": "IndexedDB cache deleted",
|
||||||
"Developer": "Developer",
|
"Toggle debug logging": "Toggle debug logging",
|
||||||
|
"Debug logging enabled": "Debug logging enabled",
|
||||||
|
"Debug logging disabled": "Debug logging disabled",
|
||||||
|
"Development": "Development",
|
||||||
"Open document": "Open document",
|
"Open document": "Open document",
|
||||||
"New document": "New document",
|
"New document": "New document",
|
||||||
"Publish": "Publish",
|
"Publish": "Publish",
|
||||||
|
|||||||
Reference in New Issue
Block a user