From ce1cab3065b78813720d54e15bb0db290ae2690b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=97=D0=BB=20=D0=93=D1=80=D0=B8?= =?UTF-8?q?=D0=B3=D0=BE=D1=80=27=D1=94=D0=B2?= Date: Fri, 18 Jul 2025 07:14:33 +0300 Subject: [PATCH] Remove unused logging code Remove functions in logging.js that are no longer used. As this action makes the circular-json npm package unused, drop it as well. --- package-lock.json | 7 --- package.json | 1 - src/js/core/logging.js | 100 ----------------------------------------- 3 files changed, 108 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2ffd6d73..c445decf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,6 @@ "dependencies": { "@msgpack/msgpack": "^3.1.2", "ajv": "^6.10.2", - "circular-json": "^0.5.9", "clipboard-copy": "^3.1.0", "debounce-promise": "^3.1.2", "howler": "^2.1.2" @@ -4280,12 +4279,6 @@ "webpack": ">=4.0.1" } }, - "node_modules/circular-json": { - "version": "0.5.9", - "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.5.9.tgz", - "integrity": "sha512-4ivwqHpIFJZBuhN3g/pEcdbnGUywkBblloGbkglyloVjjR3uT6tieI89MVOfbP2tHX5sgb01FuLgAOzebNlJNQ==", - "license": "MIT" - }, "node_modules/class-utils": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", diff --git a/package.json b/package.json index 5caa272b..0322a65d 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ "dependencies": { "@msgpack/msgpack": "^3.1.2", "ajv": "^6.10.2", - "circular-json": "^0.5.9", "clipboard-copy": "^3.1.0", "debounce-promise": "^3.1.2", "howler": "^2.1.2" diff --git a/src/js/core/logging.js b/src/js/core/logging.js index b43c7435..9eced81f 100644 --- a/src/js/core/logging.js +++ b/src/js/core/logging.js @@ -1,5 +1,4 @@ import { globalConfig } from "../core/config"; -import circularJson from "circular-json"; /* Logging functions @@ -35,80 +34,6 @@ export function createLogger(context) { return new Logger(context); } -/** - * Serializes an error - * @param {Error|ErrorEvent} err - */ -export function serializeError(err) { - if (!err) { - return null; - } - const result = { - type: err.constructor.name, - }; - - if (err instanceof Error) { - result.message = err.message; - result.name = err.name; - result.stack = err.stack; - result.type = "{type.Error}"; - } else if (err instanceof ErrorEvent) { - result.filename = err.filename; - result.message = err.message; - result.lineno = err.lineno; - result.colno = err.colno; - result.type = "{type.ErrorEvent}"; - - if (err.error) { - result.error = serializeError(err.error); - } else { - result.error = "{not-provided}"; - } - } else { - result.type = "{unkown-type:" + typeof err + "}"; - } - - return result; -} - -/** - * Serializes an event - * @param {Event} event - */ -function serializeEvent(event) { - let result = { - type: "{type.Event:" + typeof event + "}", - }; - result.eventType = event.type; - return result; -} - -/** - * Prepares a json payload - * @param {string} key - * @param {any} value - */ -function preparePayload(key, value) { - if (value instanceof Error || value instanceof ErrorEvent) { - return serializeError(value); - } - if (value instanceof Event) { - return serializeEvent(value); - } - if (typeof value === "undefined") { - return null; - } - return value; -} - -/** - * Stringifies an object containing circular references and errors - * @param {any} payload - */ -export function stringifyObjectContainingErrors(payload) { - return circularJson.stringify(payload, preparePayload); -} - export function globalDebug(context, ...args) { if (G_IS_DEV) { logInternal(context, console.log, prepareArgsForLogging(args)); @@ -136,31 +61,6 @@ function prepareArgsForLogging(args) { return result; } -/** - * @param {Array} args - */ -function internalBuildStringFromArgs(args) { - let result = []; - - for (let i = 0; i < args.length; ++i) { - let arg = args[i]; - if ( - typeof arg === "string" || - typeof arg === "number" || - typeof arg === "boolean" || - arg === null || - arg === undefined - ) { - result.push("" + arg); - } else if (arg instanceof Error) { - result.push(arg.message); - } else { - result.push("[object]"); - } - } - return result.join(" "); -} - export function logSection(name, color) { while (name.length <= 14) { name = " " + name + " ";