-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use debug from npm instead of custom debug solutions #84
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to keep the original data that was getting logged, for FDSC at least. L114/118, for example.
@ArtOfCode- Why? |
@j-f1 Mostly because in all likelihood I did it like that for a reason |
^ FDSC approved, other script authors should look at their own stuff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding Spamtracker:
I think this will improve spam tracker, the only confusing factor I see is the fact that debug is now placed as the rootlogger, so it is harder to actually see what messages are the debug category. Also, because the fact that this PR hides the "error" messages by default, it makes debugging harder, in the case something goes wrong with the script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding Spamtracker:
The script is now broken:
ERROR: Execution of script 'Spamtracker' failed! createDebug is not a function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've never used the debug module before, but it makes sense to use a single one throughout all our userscripts.
/* eslint-disable max-nested-callbacks */ | ||
|
||
(function () { | ||
"use strict"; | ||
const createDebug = typeof unsafeWindow === "undefined" ? window.debug : unsafeWindow.debug || window.debug; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this be functionally equal, but cleaner?
const createDebug = (unsafeWindow || window).debug;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Cerbrus If unsafeWindow
is undefined, that’ll throw a ReferenceError
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aw shoot, you're right @j-f1. That's a shame.
@ferrybig Does Spamtracker work again? |
@j-f1 No, Still the same error.
https://chat.stackexchange.com/transcript/message/37405109#37405109 |
@ferrybig Are you using Greasemonkey? |
@j-f1 tamper monkey on Google chrome. Could it be the case that it works for you because another userscript is importing the debug library in the window variable, as haven't installed the other userscripts |
spamtracker/spamtracker.user.js
Outdated
"use strict"; | ||
const createDebug = typeof unsafeWindow === "undefined" ? window.debug : unsafeWindow.debug || window.debug; | ||
const createDebug = typeof orginalWindow === "undefined" ? window.debug : orginalWindow.debug || window.debug; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/orginal/original/g
I’m planning to merge this today. Any objections? |
This uses npm’s
debug
module to manage logging.