Skip to content

larryprice/simple-logrotate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-logrotate

Rotate and compress log files or directories for your node application on app start.

Copyright (C) 2017 Larry Price <larry.price.dev@gmail.com>. See LICENSE for more details.

Usage

The rotate function takes in two parameters, logname and backups, and returns a promise:

const logRotate = require('simple-logrotate')

// input parameters
const logname = '/tmp/myapp'; // Path to the original log file or directory
const backups = 3;            // Number of compressed backup logs to keep

logRotate(logname, backups).then(() => {
  // insert your main logic here
}, (err) => {
  // handle internal error
  console.error(err);
});

The backup files will be named as ${logname}.x.tar.gz, where x is an integer between 1 and backups. On rotation, the log corresponding with the integer x will be removed.

About

Rotate and compress log files or directories for your NodeJS application on app start

Resources

License

Stars

Watchers

Forks

Packages

No packages published