Skip to content

Commit

Permalink
Merge pull request #41 from DrPlop/master
Browse files Browse the repository at this point in the history
Replace dynamic requires with readFileSync
  • Loading branch information
rogerc authored Oct 19, 2018
2 parents 7837b40 + e1670ce commit 5fd769e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions FileStreamRotator.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,16 @@ FileStreamRotator.setAuditLog = function (max_logs, audit_file, log_file){

if(Number(_num[1]) > 0) {
var baseLog = path.dirname(log_file.replace(/%DATE%.+/,"_filename"));

try{
if(audit_file){
var full_path = path.resolve(audit_file);
_rtn = require(full_path);
_rtn = JSON.parse(fs.readFileSync(full_path, { encoding: 'utf-8' }));
}else{
var full_path = path.resolve(baseLog + "/" + ".audit.json")
_rtn = require(full_path);
_rtn = JSON.parse(fs.readFileSync(full_path, { encoding: 'utf-8' }));
}
}catch(e){
if(e.code !== "MODULE_NOT_FOUND"){
if(e.code !== "ENOENT"){
return null;
}
_rtn = {
Expand Down

0 comments on commit 5fd769e

Please sign in to comment.