![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
A namespaced stylish logger for the browser and node.
var driftwood = require('driftwood')
var log = driftwood('a-module')
log.trace('It supports node and the browser!')
log.debug('You can', { also: 'send some arbitrary metadata!' })
var subLog = log('a-sub-module')
subLog.info('You can create loggers off loggers')
subLog.warn('So that your logs remain under the same top namespace')
subLog.error('Isn\'t this cool?')
Enabling log output globally:
driftwood.enable() // defaults to { '*': 'info' }
driftwood.enable({
'foo': 'info',
'bar:*': 'debug'
}, { persist: true }) // pass `persist: true` when in the browser to keep logging enabled across pages
Enabling log output for specific loggers or subloggers:
var log = driftwood('a-module')
var subLog = log('a-sub-module')
log.enable() // enables log and subLog
var log = driftwood('a-module')
var subLog = log('a-sub-module')
subLog.enable() // enables just subLog
log.disable() // disables log and sublog
driftwood.enable(config, options)
Enables all loggers globally using the optional log level config. The config is a map of name patterns to log level, defaulting to { '*': 'info' }
. See below for more pattern examples. You can also pass an options object to the enable function. Currently it only supports the persist
option, which lets keep logging enabled across page views (defaults to false, only supports the browser).
driftwood.disable()
Disables all loggers globally and clears the global log config.
driftwood(name, [additionalLoggers, [interceptors]])
Creates a new named log instance, optionally supplying additional loggers (e.g. sentry or devtools). additionalLoggers
should be an array of functions accepting 4 arguments:
function (name, level, now, { message, error, metadata }) {
// do whatever
}
interceptors
is an array of functions used to change those arguments before they pass into the loggers:
function (name, level, now, { message, error, metadata }) {
return [newName, newLevel, newDate, {
message: newMessage,
error: newError,
metadata: newMetadata
}]
}
For convenience, the return value can be one of:
[name, level, now, { message, error, metadata }]
, to transform each of the four arguments,{ message, error, metadata }
, to transform only the main components of the message,message
, to transform only the main message, orThe interceptors are run sequentially from left to right, before any (additional) loggers.
log(name, [additionalLoggers, [interceptors]])
Creates a sub logger that inherits the namespace of its parent.
var log = driftwood('foo') // namespace will be foo
var subLog = log('bar') // namespace will be foo:bar
When using the sub logger, any additionalLoggers
and/or interceptors
provided will run alongside the ones provided to the original logger. When using the original logger, the new functions are not run. All interceptors run before all additional loggers. Within those groups, the original functions run before the new functions. For example:
function makeImportant(name, level, now, { message }) { return 'important ' + message }
function capitalize(name, level, now, { message }) { return message.toUpperCase() }
var log = driftwood('foo', [], [makeImportant])
var subLog = log('bar', [], [capitalize])
log.info('message') // logs: important message
subLog.info('proclamation') // logs: IMPORTANT PROCLAMATION
log.enable(config)
Enables a specific logger with a config object (see driftwood.enable). This will be applied to the logger and all of it's descendants.
log.disable(config)
Disables a specific logger and all of it's descendants.
log.{LEVEL}(message, [message], [metadata/Error])
Logs a message at a level, optionally with a metadata object or error instance. Available levels:
trace
debug
info
warn
error
The last argument of the log call can be an object or an instance of Error
, which Driftwood will attempt to present in a more readable fashion. All preceding arguments will be concatenated together into a string.
By default the logger will not output anything. You need to enable it first, as specified above. Below are some examples of log configs you can pass (you can use *
as a wildcard:
{ '*': null }
- will log everything at the default level (info
){ 'foo': 'trace' }
- will log anything from the logger with the name foo
at the trace
level{ 'foo': 'trace', 'bar*': 'warn' }
- will log foo
at trace
and bar*
at warn
{ 'foo*': 'error', '*': 'info' }
- will only log up to error from foo*
and up to info from everything elseWhen running in the browser, you can pass a persist
flag to persist the log configuration into localStorage
:
driftwood.enable({ '*': 'info' }, { persist: true })
If you prefer to not have timestamps on your logs, you can turn them off in a nodejs environment by setting the DRIFTWOOD_NO_TIMESTAMP
environment variable to a truthy value.
$ DRIFTWOOD_NO_TIMESTAMP=1 node ./myApp.js
Create a main logger.js
file in your module/app:
// logger.js
var driftwood = require('driftwood')
module.exports = driftwood('my-app')
In the main part of your app, use the main logger:
// index.js
var log = require('./logger')
log.debug('We are in the entry of the app!')
In each of your submodules, create a sub logger:
// subModuleA.js
var log = require('./logger')('sub-module-a')
log.debug('We are in a submodule of the app!')
This project was created by the Engineering team at Qubit. As we use open source libraries, we make our projects public where possible.
We’re currently looking to grow our team, so if you’re a JavaScript engineer and keen on ES2016 React+Redux applications and Node micro services, why not get in touch? Work with like minded engineers in an environment that has fantastic perks, including an annual ski trip, yoga, a competitive foosball league, and copious amounts of yogurt.
Find more details on our Engineering site. Don’t have an up to date CV? Just link us your Github profile! Better yet, send us a pull request that improves this project.
FAQs
A namespaced stylish logger primarily for the browser
The npm package driftwood receives a total of 424 weekly downloads. As such, driftwood popularity was classified as not popular.
We found that driftwood demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.