59 Commits

Author SHA1 Message Date
Luke Zilioli
bf2f574c3e
fixes #987 fallback to localStorage.DEBUG if debug is not defined (#988) 2025-03-23 23:28:01 +01:00
Prabhat Dahal
a0497bd46d
Replace whitespaces in namespaces string with commas globally instead of just the first space occurrence. (#997)
Co-authored-by: Prabhat Dahal <pdahal@west.com>
2025-03-21 16:44:33 +01:00
Josh Junon
d2d6bf0bab
fix inefficient .enable() regex and .enabled() test 2024-12-06 13:27:40 +01:00
bluwy
7956a45f68 Avoid using deprecated RegExp.$1 2024-07-27 11:19:13 +02:00
calvintwr
cac39b1c5b
Fix/debug depth (#926)
* fix debug format options ignored

* moved sinon to devDependencies
2024-05-31 13:34:49 +02:00
CommanderRoot
9b334123f1
replace deprecated String.prototype.substr() (#876)
String.prototype.substr() is deprecated (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) so we replace it with slice() which works similarily but isn't deprecated.
Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
2022-03-17 14:36:24 +01:00
Taylor Everding
d177f2bc36 Remove accidental epizeuxis 2021-05-22 09:46:22 +02:00
omg
1e9d38c2e6
cache enabled status per-logger (#799)
Co-authored-by: Qix <Qix-@users.noreply.github.com>
2020-12-09 16:34:56 +01:00
Josh Junon
b6d12fdbc6 fix regression 2020-11-19 12:31:16 +01:00
Josh Junon
e2d3bc9e42 add deprecation notice for debug.destroy() 2020-09-19 10:34:59 +02:00
Josh Junon
72e7f864bd fix memory leak within debug instance 2020-09-19 10:34:59 +02:00
Bruce A. MacNaughton
22e13fe07e fix quoted percent sign 2020-07-16 21:12:18 +02:00
Milan Skuhra
6b07f9e50a Fixes: Unable to take control over selectColor #747 2020-02-23 22:09:53 +01:00
Josh Junon
0c1d5180ff remove dead code and fix lowercase comment (for linter) 2020-01-12 20:31:27 +01:00
Josh Junon
825d35a2da copy custom logger to namespace extension (fixes #646) 2018-12-19 05:04:15 +01:00
Josh Junon
5528572f9a use console.debug() in browser when available (closes #600)
also removes a branch for each logging call, slightly improving
performance in the browser.
2018-12-19 04:56:52 +01:00
Michael Bøcker-Larsen
7ef8b417a8 feat: Return namespaces string when invoking disable()
feat: Add unit tests for disable return value

fix: Correct spelling in test case description

feat: Test that disable-string works with enable again

Closes #523

docs: Add section about disable return value
2018-10-08 04:06:53 -06:00
Josh Junon
ba8a424d41 move to XO (closes #397) 2018-09-10 23:18:17 -06:00
Ruslan Boliev
e43e5fed17 add instance extends feature (#524)
* instance extends feature

* add .extend documentation

* allow empty delimiter in extend
2018-09-10 21:06:24 -06:00
Miau Lightouch
207a6a2d53 Fix nwjs support (#569) 2018-07-26 02:07:10 -06:00
Frank Febbraro
02b9ea9fd7 Add TVMLKit support (#579)
* Adding TVMLKit support

* removed the check for window/navigationDocument, instead relying on localStorage in the global context on all 'browser' based platforms
2018-06-21 13:13:12 -07:00
Qix
71d2aa77ff
Merge pull request #476 from EirikBirkeland/patch-1
Drop usage of `chrome.storage` (or make the storage backend pluggable)
2018-06-20 13:03:33 -06:00
Alexey Pelykh
225c66f719 Detect 'process' package 2018-04-20 17:48:41 +03:00
Nathan Rajlich
285dfe10a5 fix colors with supports-color@5 2017-11-09 12:35:02 -08:00
Nathan Rajlich
71169065b5 refactor to make the common code be a setup function (#507)
This is so that we can make both a Node.js instance and
web browser instance for when `--inspect` is used in Node.js.
2017-10-11 08:31:18 -07:00
Nathan Rajlich
2c0df9baf7 rename DEBUG_HIDE_TTY_DATE to DEBUG_HIDE_DATE
The date is actually only printed when output is *NOT* a TTY.

Let's just genericize the name instead.
2017-09-26 21:11:45 +02:00
Nathan Rajlich
56a3853b95 Add DEBUG_HIDE_TTY_DATE env var (#486)
Squashed commit of the following:

commit 62589c0a4e1babc5953ea30c7ef80b3867ed0a04
Author: Adrian Mejia <admejiar@cisco.com>
Date:   Sat Aug 12 15:24:45 2017 -0400

    solves merge conflict

commit 55e5c5e86812163293779e9bbad1afc252c83230
Author: Adrian Mejia <admejiar@cisco.com>
Date:   Sat Aug 12 15:21:16 2017 -0400

    docs

commit e09dec33c15fae136039c7ebd94c23000a35373f
Author: Adrian Mejia <admejiar@cisco.com>
Date:   Sat Aug 12 15:19:10 2017 -0400

    cleanup

commit 9dd6a2b9ca3b1f0d9852ecf0e64ccc6dacf04fa7
Author: Adrian Mejia <admejiar@cisco.com>
Date:   Sat Aug 12 15:05:53 2017 -0400

    enables DEBUG_HIDE_TTY_DATE
2017-09-22 15:45:06 +02:00
Ya Zhuang
c38a0166c2 remove ReDoS regexp in %o formatter (#504) 2017-09-22 00:26:33 +02:00
Nathan Rajlich
a0601e5e65 fix 2017-09-15 02:28:44 +02:00
Nathan Rajlich
e7e568a247 ignore package-lock.json 2017-09-15 00:25:50 +02:00
Mariusz Nowak
fdfa0f5f6c Fix browser detection 2017-09-13 16:02:11 +02:00
Iñaki Baz Castillo
b3ea123cc4 Disable colors in Edge and Internet Explorer (#489)
Fixes #417.
2017-08-24 12:40:18 -07:00
Nathan Rajlich
25e07c78fc don't call splice() when indexOf() returns -1 2017-08-08 14:42:25 -07:00
Nathan Rajlich
02eb3c607e fix lint 2017-08-08 14:42:25 -07:00
Nathan Rajlich
5ed41f6d92 add Web Browser 256 colors
Like #481, but for the web browser.
2017-08-08 14:42:25 -07:00
Josh Junon
65192b755d use contrast-bounded colors 2017-08-08 14:42:25 -07:00
antoine.leveugle
39eb2770a2 Use Date#toISOString() instead to Date#toUTCString() when output is not a TTY
Easier to parse programatically and contains milliseconds.

Closes #418.
2017-08-08 14:42:25 -07:00
Josh Junon
d5854f4eb6 support 256 colors
Closes #481.
2017-08-08 14:42:25 -07:00
Nathan Rajlich
bf88540737 enabled() updates existing debug instances, add destroy() function (#440)
* dynamically updatable instances

* add a `destroy()` function to debug instances

So that "dynamically created instances" can clean up after themselves
2017-08-08 14:42:25 -07:00
George Joseph
9d7c997992 Make millisecond timer namespace specific and allow 'always enabled' output (#408)
* Make millisecond timer namespace specific

When debugging node apps, I find it much more useful for the
millisecond timer to be relative to last message from the same
namespace instead of any message. This is especially true when I'm
debugging across multiple libraries or multiple levels in the same
module and I'm interested in seeing all the messages but also need to
compare times from specific levels.

* Enable 'always enabled' output

Having to deal with 2 different logging mechanisms, one for debugging
and one for normal output, can be a nuisance.  It would be much easier to
always use the same facility and semantics for both.  This patch allows
an 'always enabled' namespace to be specified by appending a single '*'
to the namespace name.

var alwaysOn = require('debug')('normal:messages*');
alwaysOn('This will always display regardless of DEBUG');
2017-08-08 14:42:25 -07:00
Nathan Rajlich
ff432e76e9 Remove DEBUG_FD (#406)
* remove DEBUG_FD

Now simply uses `process.stderr`. Breaking API change,
for the v3 branch.

Previously used internal and undocumented Node.js APIs to support
this underly used API.

Fixes #280
Closes #386

* remove DEBUG_FD from readme
2017-08-08 14:42:25 -07:00
Eirik Birkeland
da51af8314 Simplify and improve
The browser version assumes that chrome.storage.local uses an API which is compatible with localStorage; which is not the case. Even though I am using chrome.storage.local for my Chrome extension, I would much prefer to keep debug's variable in localStorage, as I consider chrome.storage.local the 'private space' of my extension.

This change obviates the need to support multiple storage types. But if storage type is important, how about supporting a custom storage facility, including chrome.storage.sync? I.e. the user would provide an object that follows the conventions. Just a thought - I certainly don't see the need at this point though.
2017-07-17 18:45:45 +02:00
Marc MacLeod
2482e08e4e Check for undefined on browser globals (#462)
* Check for undefined on browser globals.

Not all environments include these globals. For example, web workers do not have global window objects.

* remove redundant global checks
2017-05-18 09:38:54 -07:00
Douglas Wilson
1351d2f91f Inline extend function in node implementation (#452) 2017-05-10 15:51:27 -07:00
Andrew E. Rhyne
cae07b70c9 cleanup browser tests and fix null reference check on window.documentElement.style.WebkitAppearance (#447) 2017-04-27 08:59:02 -07:00
Lucian Buzzo
1f01b70f88 Fix bug that would occure if process.env.DEBUG is a non-string value. (#444)
Connects to #443
2017-04-20 11:04:28 -07:00
Paul Betts
0fb8ea4730 LocalStorage returns undefined for any key not present (#431) 2017-03-13 20:43:57 -07:00
slavaGanzin
23bc780b84 fix DEBUG_MAX_ARRAY_LENGTH 2017-02-22 11:18:13 -08:00
Pooya Parsa
37e14d6aad Whitelist DEBUG_FD for values 1 and 2 only Fixes #410 (#415)
* Hide in DEBUG_FD deprecation warning in Webstorm Fixes #410

+ Intellij idea

* Hide in DEBUG_FD deprecation warning in Webstorm Fixes #410

* whitelist DEBUG_FD for values 1 and 2 only

* Use appreciate depreciation message
2017-01-23 17:42:32 -08:00
vgoma
78ae6c9412 Fixed IE8 "Expected identifier" error 2017-01-16 22:00:27 +03:00