Git Product home page Git Product logo

egg-logger-sls-pro's Introduction

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

egg-logger-sls-pro's People

Watchers

 avatar

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.