1.0.8 • Published 5 years ago

egg-logger-sls-pro v1.0.8

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

egg-logger-sls-pro

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Description

  1. egg 的阿里云日志插件。
  2. 基于 aliyun sdkegg-logger

Install

$ npm i egg-logger-sls-pro --save

Usage

// {app_root}/config/plugin.js
exports.loggerSlsPro = {
  enable: true,
  package: 'egg-logger-sls-pro'
};

Configuration

// {app_root}/config/config.default.js
exports.loggerSlsPro = {
  level: 'INFO',
  flushInterval: 1000,
  maxBufferLength: 1000,
  sls: {
    topic: 'your-topic-name',
    accessKeyId: '在阿里云sls申请的 accessKeyId',
    secretAccessKey: '在阿里云sls申请的 secretAccessKey',
    // 根据你的 sls project所在地区选择填入
    // 北京:http://cn-beijing.log.aliyuncs.com
    // 杭州:http://cn-hangzhou.log.aliyuncs.com
    // 青岛:http://cn-qingdao.log.aliyuncs.com
    // 深圳:http://cn-shenzhen.log.aliyuncs.com

    // 注意:如果你是在 ECS 上连接 log,可以使用内网地址,速度快,没有带宽限制。
    // 北京:cn-hangzhou-intranet.log.aliyuncs.com
    // 杭州:cn-beijing-intranet.log.aliyuncs.com
    // 青岛:cn-qingdao-intranet.log.aliyuncs.com
    // 深圳:cn-shenzhen-intranet.log.aliyuncs.com
    endpoint: 'your-endpoint',
    //目前支持最新的 api 版本, 不需要修改
    apiVersion: '2015-06-01',
    project: 'your-project-name',
    logStore: 'your-logStore-name'
  }
};

custom put msg content

your can set formatter fn in config to do this, just like

exports.loggerSlsPro = {
  sls: {
    // ...other config
    // your custom formatter
    formatter: (level, args, meta) {
    // your formatter code here
    // must return like this
      return {
        time: 1565615342, // unix sec
        contents: [
          {
            key: 'key',
            value: 'value'
          }
        ]}
      }
  }
}

see config/config.default.js for more detail.

Example

// send a info message
ctx.logger.info('message');
// or
app.logger.info('message');

Questions & Suggestions

Please open an issue here.

License

MIT

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago