Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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 0 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.