New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

express-log-middleware

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-log-middleware

### 说明

  • 1.0.0
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

express-log-middleware

说明

app.use(
	require('express-log-middleware')(config)
);

nametypedescription
config.modelstring项目模板名称(用于指定Elasticsearch中的index) 必填项
config.levelstring日志输出级别
config.logDirstring日志输出路径
config.fetchBusinessDatafunction增加额外信息到日志的
config.paramsGeneratorfunction定制params

使用实例

//model 是Elasticsearch使用的index名称
app.use(require('express-log-middleware')({model: 'education_cloud'}));  //不对参数进行处理

app.use(require('express-log-middleware')({model: 'education_cloud', paramsGenerator: (req) => ({userId: req.user.id})}));  //定制自己的参数

app.use(require('express-log-middleware')({ //增加额外的信息
  model: 'education_cloud',
  fetchBusinessData: function (params, req) {
    let user = req.user || {};
    const customer = req.customer || {};
    return {
      userId: user.id || -1,
      customeUrl:customer.url || '-'
    }
  }
}));

req.logger.log('xxx')
req.logger.error('xxx')

FAQs

Package last updated on 02 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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