
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@vrbo/pino-rotating-file
Advanced tools
A hapi-pino log transport for splitting logs into separate, automatically rotating files.
A pino transport for filtering log entries and writing them to a file that automatically rotates. Log entries that are not filtered continue out of stdout.
This is useful for logging when you want different entries in different rotating files. Using rotating files allows you to roll logs across multiple files so that individual file sizes don't grow too large and old files get deleted.
At its core, this processor takes a simple config js file that contains an output path and additional options for the rotation. Under the hood, it uses the rotating-file-stream - check out the options. It also has a filter function to determine if the log entry should go to the log file, or be forwarded through to stdout.
Install this module as a dependency in your project with npm install @vrbo/pino-rotating-file
After this, you can reference it as rotate-logs
in your npm scripts in your package.json file when running your main application, like this:
...
"scripts": {
"start": "node ./index.js | rotate-logs --config=.request-log.js"
}
...
.request-log.js
module.exports = {
filter(data) {return !!data.req},
output: {
path: "request.log", // name of file
options: {
path: "logs/", // path to write files to
size: "10M", // max file size
rotate: 5 // keep 5 rotated logs
}
}
}
If no
--config
flag is given, it will look for the file.rotate.js
by default
You can chain all these together to split your logs into separate, automatically rotating log files:
...
"scripts": {
"start": "node ./index.js | rotate-logs --config=.request-log.js | rotate-logs --config=.error-log.js | rotate-logs --config=.server-log.js"
}
...
Where .request-log.js
pulls all the logs that have req
tags, .error-log.js
pulls all the logs with error
tags, and .server-log.js
puts all the rest into another file.
NOTE: if the config provided does not exist or fails to load, then all logs will be passed to stdout.
To disable formatting logs into JSON and take advantage of file rotation only, simply add isJson: false
to the output
object in your configuration file:
module.exports = {
filter(data) {return !!data.req},
output: {
path: "request.log",
isJson: false // JSON formatting will be disabled,
options: {
// Options configured here are passed along to rotating-file-stream.
// See the Introduction of this README for a link to valid options.
...
}
}
}
FAQs
A hapi-pino log transport for splitting logs into separate, automatically rotating files.
The npm package @vrbo/pino-rotating-file receives a total of 1,508 weekly downloads. As such, @vrbo/pino-rotating-file popularity was classified as popular.
We found that @vrbo/pino-rotating-file demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 11 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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.