debug icon indicating copy to clipboard operation
debug copied to clipboard

Exploratory PR for backwards-compatible changes & cross-env alignment: timeFormat

Open webketje opened this issue 2 years ago • 1 comments

I started this effort because I was in sore need of localized dates (we have Java & Node microservices and it's a pain that one takes into account timezone while the other does not). Then I realized there was a lot more I could do that would be both backwards-compatible, more powerful and more aligned across browser and Node. So this PR:

  • Adds timeFormat option to debug instances, settable as DEBUG_TIME_FORMAT env var
  • Deprecates hideDate option, equated to timeFormat === 'none'
  • Allows timeFormat of choice: none, iso, diff, or localized (taking into account process.env.TZ in Node, and timezoneOffset in browser)
  • Normalizes behavior across browser & Node: all timeFormats are available in both, but the defaults are kept as-is.
  • Deprecates createDebug.humanize as public member and adds createDebug.withTimeFormat helper instead
  • Documents this in the README.
  • Adds debug format tests that are compatible with browser & Node.

@Qix- I was surprised at how outdated (dev)Dependencies are and was unable to run npm test (only mocha test.js directly), and dind't find any CI script. The browserify build was not documented so I added an NPM script for it.. It may be useful to add it to the NPM files for those of us wanting to use debug in the browser by copying the dist to an asset folder. I think this change is fully backwards-compatible (at least all tests succeed including the 5 new ones I added)

webketje avatar Nov 03 '22 23:11 webketje

@Qix- feedback?

webketje avatar Feb 16 '23 16:02 webketje