npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

log-agent

v0.2.1

Published

用于监听日志文件变动,并根据需求进行筛选、上报 kafka 或者报警

Downloads

4

Readme

log-agent

build status Test coverage GitHub license node version

NPM

本项目用于监听日志文件变动,可以对于读取到的日志做筛选,可以将日志通过 queue-schedule 或者 @yunnysunny/node-alarm 工具进行日志转发。

安装

yarn add log-agent

测试

npm run test

示例

const LogAgent = require('log-agent');
const NodeAlarm = require('@yunnysunny/node-alarm');
const WXWORK_CONFIG = {
    type: NodeAlarm.ALARM_TYPE_WXWORK,
    options: {
        // 机器人地址
        url: 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=637cc457-6e6f-44a5-99ad-2e3d825482b2',
        msgType: 'markdown'//支持 text 和 markdown 两种类型
    }
};
const alarm = new NodeAlarm([WXWORK_CONFIG]);
/*
 * 默认每一行都会作为一个日志实例,输入 mutliLineRegexStart 则支持多行匹配。
 * mutliLineRegexStart 的正则匹配成功后,说明当前日志项还未结束,
 * 直到遇到非 mutliLineRegexContent 正则匹配的行算结束。
 * 
 * 指定 filterRegex 后,当前条目日志只有含有 Error 关键字才会被处理。
 * 
 * 指定 alarm 后,所有 run 函数返回的日志条目,同时也会被通过 alarm 对象发送出去。
 */
const config = {
    logPath:['/app/log/pm2-error-*.log'],
    reportInterval:1000,
    mutliLineRegexStart:'Error',
    mutliLineRegexContent:'at ',
    filterRegex: 'Error',
    alarm
};

const agent = new LogAgent(config);
agent.run(function(err, logs) {
    console.log(logs);
});
//agent.stop();// 停止收集日志

文档

参见这里.