Skip to content

Commit

Permalink
Include timing info in pbjs_debug=true console log
Browse files Browse the repository at this point in the history
Include the number of milliseconds since the page load
  • Loading branch information
yonran committed Jun 29, 2020
1 parent 2f7b2f2 commit e957c83
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,23 @@ export function logError() {
}
}

let getTimestamp
if (window.performance && window.performance.now) {
getTimestamp = function getTimestamp() {
// truncate any partial millisecond
return window.performance.now() | 0
}
} else {
const initTime = +new Date()
getTimestamp = function getTimestamp() {
return new Date() - initTime
}
}

function decorateLog(args, prefix) {
args = [].slice.call(args);
prefix && args.unshift(prefix);
args.unshift(getTimestamp())
args.unshift('display: inline-block; color: #fff; background: #3b88c3; padding: 1px 4px; border-radius: 3px;');
args.unshift('%cPrebid');
return args;
Expand Down

0 comments on commit e957c83

Please sign in to comment.