Skip to content

Commit

Permalink
Merge pull request godotengine#31 from JiepengTan/spx4.2.2
Browse files Browse the repository at this point in the history
Add log level config
  • Loading branch information
JiepengTan authored Dec 23, 2024
2 parents 5e11488 + 42c8c4f commit d68e9df
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
15 changes: 14 additions & 1 deletion platform/web/js/engine/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
* @typedef {Object} EngineConfig
*/
const EngineConfig = {}; // eslint-disable-line no-unused-vars
const LOG_LEVEL_VERBOSE = 0
const LOG_LEVEL_LOG = 1
const LOG_LEVEL_WARNING = 2
const LOG_LEVEL_ERROR = 3
const LOG_LEVEL_NONE = 4

let engineLogLevel = LOG_LEVEL_VERBOSE
/**
* @struct
* @constructor
Expand Down Expand Up @@ -197,6 +203,9 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused-
* @type {?function(...*)}
*/
onPrint: function () {
if (engineLogLevel > LOG_LEVEL_LOG) {
return
}
console.log.apply(console, Array.from(arguments)); // eslint-disable-line no-console
},
/**
Expand All @@ -212,6 +221,9 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused-
* @type {?function(...*)}
*/
onPrintError: function (var_args) {
if (engineLogLevel > LOG_LEVEL_ERROR) {
return
}
console.error.apply(console, Array.from(arguments)); // eslint-disable-line no-console
},
};
Expand Down Expand Up @@ -268,6 +280,7 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused-
// Wasm data
this.wasmGdspx = parse('wasmGdspx', this.wasmGdspx);
this.wasmEngine = parse('wasmEngine', this.wasmEngine);
engineLogLevel = parse('logLevel', engineLogLevel);
};

/**
Expand All @@ -284,7 +297,7 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused-
'noExitRuntime': false,
'dynamicLibraries': [`${loadPath}.side.wasm`],
'instantiateWasm': function (imports, onSuccess) {
WebAssembly.instantiate(curBuffer, imports).then((result)=> {
WebAssembly.instantiate(curBuffer, imports).then((result) => {
onSuccess(result['instance'], result['module']);
});
return {};
Expand Down
1 change: 0 additions & 1 deletion platform/web/js/libs/library_godot_input.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ const GodotEditorEventHandler = {
while (GodotOS._frame_num - start_frame < GodotOS._min_wait_frame_num) {
await GodotOS.get_sync_done_promise()
}
console.log("wait_fs_sync_done done start at ", start_frame, " => ", GodotOS._frame_num)
if (resolve) {
resolve()
}
Expand Down
3 changes: 0 additions & 3 deletions platform/web/js/libs/library_godot_os.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,6 @@ const GodotFS = {
const analysis = FS.analyzePath(path);
if (analysis.exists && analysis.object && FS.isDir(analysis.object.mode)) {
FS.rmdir(path);
console.log(`Directory '${path}' was removed.`);
} else {
console.log(`Directory '${path}' does not exist.`);
}
},

Expand Down

0 comments on commit d68e9df

Please sign in to comment.