Skip to content

Commit d9e930c

Browse files
committed
Set a more sane default log level
Logging /alone/ takes 50%+ of HTTPS Everywhere's profile time in Chrome (!) Chrome will log & buffer console.log() even when the console is closed. This means that for 99.9% of users (who never open the console), Chrome wastes staggering amounts of time logging and buffering extremely verbose data. For now, this just sets a default log level and includes adds the .warn() function. TODO (Upcoming commit): Add a UI element to change the default log level. Developers can simply type (in the console): DEFAULT_LOG_LEVEL=1; Signed-off-by: Nick Semenkovich <semenko@alum.mit.edu>
1 parent b81c7fa commit d9e930c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

chromium/util.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ DBUG=2;
33
INFO=3;
44
NOTE=4;
55
WARN=5;
6+
// FYI: Logging everything is /very/ slow. Chrome will log & buffer
7+
// these console logs even when the debug tools are closed. :(
8+
9+
// TODO: Add an easy UI to change the log level.
10+
// (Developers can just type DEFAULT_LOG_LEVEL=1 in the console)
11+
DEFAULT_LOG_LEVEL=4;
612
function log(level, str) {
7-
console.log(str);
13+
if (level >= DEFAULT_LOG_LEVEL) {
14+
if (level === WARN) {
15+
// Show warning with a little yellow icon in Chrome.
16+
console.warn(str);
17+
}
18+
console.log(str);
19+
}
820
}

0 commit comments

Comments
 (0)