Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

file-stream-rotator

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-stream-rotator - npm Package Compare versions

Comparing version 0.5.6 to 0.5.7

48

FileStreamRotator.js

@@ -255,4 +255,5 @@ 'use strict';

* @param {Array} audit.files
* @param {Boolean} verbose
*/
FileStreamRotator.writeAuditLog = function(audit){
FileStreamRotator.writeAuditLog = function(audit, verbose){
try{

@@ -262,3 +263,5 @@ mkDirForFile(audit.auditLog);

}catch(e){
console.error(new Date(),"[FileStreamRotator] Failed to store log audit at:", audit.auditLog,"Error:", e);
if (verbose) {
console.error(new Date(),"[FileStreamRotator] Failed to store log audit at:", audit.auditLog,"Error:", e);
}
}

@@ -274,4 +277,5 @@ };

* @param file.date
* @param {Boolean} verbose
*/
function removeFile(file){
function removeFile(file, verbose){
if(file.hash === crypto.createHash('md5').update(file.name + "LOG_FILE" + file.date).digest("hex")){

@@ -283,3 +287,5 @@ try{

}catch(e){
console.error(new Date(), "[FileStreamRotator] Could not remove old log file: ", file.name);
if (verbose) {
console.error(new Date(), "[FileStreamRotator] Could not remove old log file: ", file.name);
}
}

@@ -293,4 +299,5 @@ }

* @param {String} name Name to use for symbolic link
* @param {Boolean} verbose
*/
function createCurrentSymLink(logfile, name) {
function createCurrentSymLink(logfile, name, verbose) {
let symLinkName = name || "current.log"

@@ -311,3 +318,5 @@ let logPath = path.dirname(logfile)

} catch (e) {
console.error(new Date(), "[FileStreamRotator] Could not create symlink file: ", current, ' -> ', logfileName);
if (verbose) {
console.error(new Date(), "[FileStreamRotator] Could not create symlink file: ", current, ' -> ', logfileName);
}
}

@@ -358,4 +367,5 @@ }

* @param {EventEmitter} stream
* @param {Boolean} verbose
*/
FileStreamRotator.addLogToAudit = function(logfile, audit, stream){
FileStreamRotator.addLogToAudit = function(logfile, audit, stream, verbose){
if(audit && audit.files){

@@ -383,3 +393,3 @@ // Based on contribution by @nickbug - https://github.com/nickbug

}
removeFile(file);
removeFile(file, verbose);
stream.emit("logRemoved", file)

@@ -393,3 +403,3 @@ return false;

audit.files.filter(function(file){
removeFile(file);
removeFile(file, verbose);
stream.emit("logRemoved", file)

@@ -402,3 +412,3 @@ return false;

FileStreamRotator.writeAuditLog(audit);
FileStreamRotator.writeAuditLog(audit, verbose);
}

@@ -442,2 +452,3 @@

let auditLog = self.setAuditLog(options.max_logs, options.audit_file, options.filename);
self.verbose = (options.verbose !== undefined ? options.verbose : true);

@@ -457,3 +468,3 @@ var fileSize = null;

if(moment().format(dateFormat) != moment().endOf("day").format(dateFormat) || moment().format(dateFormat) == moment().add(1,"day").format(dateFormat)){
if(options.verbose){
if(self.verbose){
console.log(new Date(),"[FileStreamRotator] Changing type to custom as date format changes more often than once a day or not every day");

@@ -477,3 +488,2 @@ }

}
var verbose = (options.verbose !== undefined ? options.verbose : true);

@@ -518,3 +528,3 @@ if(fileSize){

if (verbose) {
if (self.verbose) {
console.log(new Date(),"[FileStreamRotator] Logging to: ", logfile);

@@ -528,3 +538,3 @@ }

if ((curDate && frequencyMetaData && (staticFrequency.indexOf(frequencyMetaData.type) > -1)) || fileSize > 0) {
if (verbose) {
if (self.verbose) {
console.log(new Date(),"[FileStreamRotator] Rotating file: ", frequencyMetaData?frequencyMetaData.type:"", fileSize?"size: " + fileSize:"");

@@ -547,5 +557,5 @@ }

// console.log("new log", newLog)
stream.auditLog = self.addLogToAudit(newLog,stream.auditLog, stream)
stream.auditLog = self.addLogToAudit(newLog,stream.auditLog, stream, self.verbose)
if(options.create_symlink){
createCurrentSymLink(newLog, options.symlink_name)
createCurrentSymLink(newLog, options.symlink_name, self.verbose)
}

@@ -566,3 +576,3 @@ if(options.watch_log){

// console.log("ADDING WATCHER", newLog)
logWatcher = createLogWatcher(newLog, options.verbose, function(err,newLog){
logWatcher = createLogWatcher(newLog, self.verbose, function(err,newLog){
stream.emit('createLog', newLog)

@@ -603,3 +613,3 @@ })

if (verbose) {
if (self.verbose) {
console.log(new Date(),require('util').format("[FileStreamRotator] Changing logs from %s to %s", logfile, newLogfile));

@@ -634,3 +644,3 @@ }

} else {
if (verbose) {
if (self.verbose) {
console.log(new Date(),"[FileStreamRotator] File won't be rotated: ", options.frequency, options.size);

@@ -637,0 +647,0 @@ }

{
"name": "file-stream-rotator",
"version": "0.5.6",
"version": "0.5.7",
"description": "Automated stream rotation useful for log files",

@@ -5,0 +5,0 @@ "main": "FileStreamRotator.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc