Skip to content

Commit

Permalink
[unity]console添加debug、timeLog接口实现 (#1946)
Browse files Browse the repository at this point in the history
  • Loading branch information
alanwalk authored Dec 18, 2024
1 parent 21e2f67 commit 1e1d1b7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions unity/Assets/core/upm/Runtime/Resources/puerts/log.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ if (UnityEngine_Debug || !global.console) {
if (console_org) console_org.error.apply(null, Array.prototype.slice.call(arguments));
UnityEngine_Debug.LogError(toString(arguments));
}

console.debug = function() {
if (console_org) console_org.debug.apply(null, Array.prototype.slice.call(arguments));
UnityEngine_Debug.Log(toString(arguments));
}

console.trace = function() {
if (console_org) console_org.trace.apply(null, Array.prototype.slice.call(arguments));
Expand All @@ -83,6 +88,14 @@ if (UnityEngine_Debug || !global.console) {
console.time = function(name){
timeRecorder.set(name,+new Date);
}
console.timeLog = function(name, ...args){
const startTime = timeRecorder.get(name);
if(startTime){
console.log(String(name)+": "+(+new Date - startTime)+" ms", ...args);
}else{
console.warn("Timer '" + String(name)+ "' does not exist");
};
}
console.timeEnd = function(name){
const startTime = timeRecorder.get(name);
if(startTime){
Expand Down

0 comments on commit 1e1d1b7

Please sign in to comment.