mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-09 16:21:51 +00:00
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.
This commit is contained in:
parent
114a1f9d74
commit
ce1cab3065
7
package-lock.json
generated
7
package-lock.json
generated
@ -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",
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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<any>} 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 + " ";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user