![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
logrotate-stream
Advanced tools
A Writable Stream that supports linux logrotate style options
On the command line:
node app.js 2>&1 | logrotate-stream app.log --keep 3 --size '50m' --compress
As a module:
var stream = require('logrotate-stream')
, toLogFile = stream({ file: './test.log', size: '100k', keep: 3 });
someStream.pipe(toLogFile);
Rotating logs that are being written to with stdio redirection sucks. Using a
utility like logrotate
doesn't automagically update your processes log file
descriptor and you end up with several empty logs and one mega rotated log.
There's a couple ways to try and deal with this, but they all fall short:
winston
's log rotation feature for nodejs appsThis requires adding a new dependency and possibly code changes around logging logic.
Often times, production apps can't be restarted willy-nilly
copytruncate
feature of logrotate
This only works if you don't need to guarantee that all of your log lines are
persisted. copytruncate
performs a non-atomic copy before truncating the
original log, which means you can lose data in the process if the copy is slow.
logrotate-stream
tries to remedy this situation by acting as an intermediary
between the application and the file system, piping stdin
to log files and
rotating those logfiles when necessary.
If you find yourself using logrotate-stream with upstart, there's a few things
to consider. Piping to logrotate-stream in your exec
line will cause upstart
to track the pid of the logrotate process rather than your app. While stopping
will still work (most likely emitting an EPIPE error on your app before
exiting), it would be better if you used a named pipe to redirect your apps output:
chdir /path/to/app
pre-start script
# create a named pipe
mkfifo logpipe
# create a backgrounded logrotate-stream process and
# redirect the named pipe data to it
logrotate-stream app.log --keep 3 --size 50m < logpipe &
end script
# start the app, redirecting stdout & stderr to the named pipe
exec /usr/local/bin/node index.js > logpipe 2>&1
This setup will register the correct pid with upstart, make sure your stdio is forwarded to logrotate-stream, and will properly kill the logrotate-stream process when your app is stopped.
The file log file to write data to.
The max file size of a log before rotation occurs. Supports 1024
, 1k
, 1m
, 1g
The number of rotated log files to keep (including the primary log file). Additional logs are deleted no rotation.
Optionally compress rotated files with gzip.
With npm do:
npm install logrotate-stream
FAQs
Pipe log data to a stream, fuggetabout rotation
The npm package logrotate-stream receives a total of 6,491 weekly downloads. As such, logrotate-stream popularity was classified as popular.
We found that logrotate-stream 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
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.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.