https://github.com/rokid/aliyun-sls-stream
https://github.com/rokid/aliyun-sls-stream
aliyun bunyan log sls stream
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/rokid/aliyun-sls-stream
- Owner: rokid
- Created: 2017-12-28T03:04:22.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-29T09:03:47.000Z (over 8 years ago)
- Last Synced: 2024-09-27T09:35:26.990Z (almost 2 years ago)
- Topics: aliyun, bunyan, log, sls, stream
- Language: JavaScript
- Size: 41 KB
- Stars: 0
- Watchers: 9
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 阿里云 SLS Stream
阿里云 SLS PutLogs Stream
## 使用方法
1. 直接使用
```js
const AliyunSlsStream = require('aliyun-sls-stream')
const stream = new AliyunSlsStream({
accessKeyId: 'your_very_secured_access_key_id',
secretAccessKey: 'your_very_secured_secret_access_key',
endpoint: 'an_aliyun_endpoint_for_sls', // refer to https://help.aliyun.com/document_detail/29008.html?spm=5176.doc28984.2.5.CMkSh1 for more details
project: process.env.ALIYUN_PROJECT,
logStore: process.env.ALIYUN_LOG_STORE
})
stream.write('Hello from the other side')
stream.write({ foo: 'bar' })
```
2. 通过 `bunyan` 使用
```js
const bunyan = require('bunyan')
const AliyunSlsStream = require('aliyun-sls-stream')
const log = bunyan.createLogger({
name: 'foo',
streams: [{
type: 'raw',
stream: new AliyunSlsStream({
accessKeyId: 'your_very_secured_access_key_id',
secretAccessKey: 'your_very_secured_secret_access_key',
endpoint: 'an_aliyun_endpoint_for_sls', // refer to https://help.aliyun.com/document_detail/29008.html?spm=5176.doc28984.2.5.CMkSh1 for more details
project: process.env.ALIYUN_PROJECT,
logStore: process.env.ALIYUN_LOG_STORE
}),
reemitErrorEvents: true
}],
level: 'debug'
})
log.debug('foobar')
log.debug({ foo: 'bar' }, 'foobar')
log.debug({ foo: 'bar' }, 'foobar: %s', ['foo', 'bar'])
```