![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
We take logger as a function to receive a record and output to a stream, and elecPen
is a simple logger creator.
elecPen(writable, prefix, dateFormat)
Param | Description |
---|---|
writable | A writable stream for logging |
prefix | The prefix of the record |
dateFormat | Date format for logger or pass true to use the default format |
A set of logger is provided by a default logger creator which provide some useful logger like info
or error
.
Option | Type | Description |
---|---|---|
infoFile | string, function | File name for logging info and verbose |
errFile | string, function | File name for logging error and warning |
timestamp | string, boolean | Date format for logger or pass true to use the default format |
append | boolean | If file exists, append new entries to it instead of truncating |
You can you a set of default logger:
// use default logger
const opts = {
infoFile: 'info.log', // record info and verbose
errFile: 'err.log', // record error and warning
timestamp: true,
append: true // default to true
}
const http = requrie('http')
const logger = require('elecpen').defaultLogger(opts)
http.createServer((req, res) => {
logger.info('Recieve a request. Path: %s', req.path)
res.end('Hello world.')
})
.listen(4000, _ => {
logger.info('Server listening...')
})
Dynamic file name is supported, and it is useful to record log by separated file.
const opts = {
infoFile () {
const now = new Date()
return `log-${now.getFullYear()}-${now.getMonth() + 1}`
},
errFile: 'err.log'
}
const logger = require('elecpen').defaultLogger(opts)
logger.info('Hello World!')
Or create you own logger:
const fs = require('fs')
const elecpen = require('elecpen')
const recorder = elecpen.streamRecorder()
const log = function (msg) {
// dynamic stream
const stream = recorder(
_ => `log-${Date.now()}.log`,
name => fs.createWriteStream(name, { flags: 'a' })
)
stream && elecpen(stream, 'Message', timestamp)(msg)
}
log('Hello World!')
MIT
FAQs
a simple logger
The npm package elecpen receives a total of 1 weekly downloads. As such, elecpen popularity was classified as not popular.
We found that elecpen demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.