Giter VIP home page Giter VIP logo

file-guard's Introduction

file-guard

A file guard, notify you when logs increase exceeds limits

Installation

npm install file-guard

Usage

example

'use strict'

const FileGuard = require('file-guard')
const moment = require('moment')

const file_filter = function () {
  const hour = moment().format('YYYY-MM-DD-HH')
  return `*.${hour}.log`
}
// const file_filter = '*.log'

const guard = FileGuard({
  'root': 'path/to/logs',
  'file_filter': file_filter,
  'rate_limit': {'change_count': 4, 'in_milliseconds': 1 * 60 * 1000}, // 4 changes in 1 minute
  'schedule_rule': '0 0 0 * * *'
})

guard.on('alert', function (obj) {
  console.log('on alert ', obj)
})

guard.startWatching()

parameter

root: path in which to start watching.

fileFilter: a string (e.g., *.js) which is matched using minimatch, or a function which return a matched minimatch string.

rate_limit: the max change rate limit.

schedule_rule: the rule to refresh the file_filter, see node-schedule for more.

file-guard's People

Contributors

danlanxiaohei avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

taibushuang

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.