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

egg-logrotater

Package Overview
Dependencies
Maintainers
6
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-logrotater - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

29

app/schedule/rotateByFile.js

@@ -11,14 +11,25 @@ 'use strict';

const logger = app.coreLogger;
const rotateLogDirs = app.config.logger.rotateLogDirs;
const messenger = app.messenger;
exports.schedule = {
type: 'worker', // 类型 为 `all` 的定时任务在到执行时间时所有的进程都会执行
cron: '0 0 * * *', // 直接指定执行的间隔,支持 ms 格式的字符串或者毫秒级别的数值
type: 'worker', // only one worker run this task
cron: '0 0 * * *', // run every day at 00:00
};
exports.task = function* () {
let logDirs = [];
// try to use rotateLogDirs first
if (app.config.logger.rotateLogDirs && app.config.logger.rotateLogDirs.length > 0) {
logDirs = logDirs.concat(app.config.logger.rotateLogDirs);
}
// auto find all log dir
for (const key in app.loggers) {
const logDir = path.dirname(app.loggers[key].options.file);
if (logDirs.indexOf(logDir) === -1) {
logDirs.push(logDir);
}
}
const maxDays = app.config.logrotater.maxDays;
if (maxDays && maxDays > 0) {
try {
yield rotateLogDirs.map(logdir => removeExpiredLogFiles(logdir, maxDays));
yield logDirs.map(logdir => removeExpiredLogFiles(logdir, maxDays));
} catch (err) {

@@ -30,3 +41,3 @@ logger.error(err);

try {
yield rotateLogDirs.map(logdir => renameLogfiles(logdir));
yield logDirs.map(logdir => renameLogfiles(logdir));
} catch (err) {

@@ -37,5 +48,5 @@ logger.error(err);

// tell every one to reload logger
logger.info('[egg-logrotater] broadcast log-reload to workers');
messenger.sendToApp('log-reload');
messenger.sendToAgent('log-reload');
logger.info('[egg-logrotater] broadcast log-reload to workers, logDirs: %j', logDirs);
app.messenger.sendToApp('log-reload');
app.messenger.sendToAgent('log-reload');
};

@@ -42,0 +53,0 @@

1.0.1 / 2016-08-10
==================
* fix: auto find log file dirs to do rotate (#2)
1.0.0 / 2016-07-26

@@ -3,0 +8,0 @@ ==================

{
"name": "egg-logrotater",
"version": "1.0.0",
"version": "1.0.1",
"description": "logrotater for egg",

@@ -5,0 +5,0 @@ "eggPlugin": {

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