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

evelog

v1.1.1

Published

node线上运行监控日志模块暂时只接入了express框架 后期可以继续接入其他框架,Clog名字占用了,治好使用evelog了

Downloads

2

Readme

本人暂时还不会md语法 (速学速学)!

简单说明一下

evelog模块如果要投入使用的话 你可以这样

npm install evelog

目前只支持了express 框架

在app.js 中

let Clog(你也可以用别的命名) = require('evelog')

Clog.configuration({ replaceConsole: true,//是否替换全局console.error输出到日志文件 默认是false mypath: 'xxxxxx',//你要输出的文件夹 会在里面自动创建日志文件 前提是你得产生请求 默认是模块包下面的logdir文件夹 所以你不能写./logdir maxSave: 30,//最大存储天数 超过这个日期的会日志文件会自动删除 正在完善的新功能 不建议使用 maxSize:1024000,//日志文件的最大承载量 默认1M 超过会以编号自动分割 maxSumSize: 5368709120// 总文件大小 如果超过10G 会自动删除前三个 一天检测一次 confjson: path.join(__dirname,'./elogconfig.json')//日志标准文件 必须要有 如果没有则不能写自己的路径 就默认输出在./logdir });

app.use(Clog.use);

这样就Clog就会去捕获请求进而输出日志

但还没完 在这个 app.use(function (err, req, res, next) { setTimeout(e => { //重点在这 需要加上一定的延迟 捕获直接错误 ,你说回调错误怎么办? 放心我已经帮你解决了 Clog.log({ lv: 'ERROR', content: e }); }, 300, err); // set locals, only providing error in development res.locals.message = err.message; res.locals.error = req.app.get('env') === 'development' ? err : {};

// render the error page
res.status(err.status || 500);
res.end('error');

});

confjson的内容为 {"numbering":0,"today":"2017-09-19"} 很明显 一个编号初始值 一个日期 这个日期会自动由模块更新 初始值会每天刷新一次变为0

日志文件是以当前日期开头 2017-09-20-0.log 最后这个0是confjson配置里的 numbering 前面的日期就是 today

哦 差点漏了 还有日志等级 普通请求会以INFO记录 错误就是ERROR 不过我们基本也就是为了ERROR来的

相信这样看来已经很简单的就能使用了

当初开发这个模块是因为市面上的不好用 并且不会记录错误可能我使用不当吧