Socket
Socket
Sign inDemoInstall

aliyun-sls-stream

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aliyun-sls-stream - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

4

index.js

@@ -60,3 +60,5 @@ 'use strict'

if (typeof chunk === 'string') {
chunk = {
message: chunk
}
}

@@ -63,0 +65,0 @@ this.__cache.push(Object.assign({}, chunk, {

{
"name": "aliyun-sls-stream",
"version": "0.0.1",
"version": "0.0.2",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -7,5 +7,23 @@ # 阿里云 SLS Stream

1. 通过 `bunyan` 使用
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')

@@ -12,0 +30,0 @@ const AliyunSlsStream = require('aliyun-sls-stream')

@@ -7,2 +7,9 @@ const { test } = require('ava')

test.beforeEach(async t => {
const stream = new AliyunSlsStream({
accessKeyId: process.env.ALIYUN_ACCESS_KEY_ID,
secretAccessKey: process.env.ALIYUN_SECRET_ACCESS_KEY,
endpoint: process.env.ALIYUN_ENDPOINT,
project: process.env.ALIYUN_PROJECT,
logStore: process.env.ALIYUN_LOG_STORE
})
const log = bunyan.createLogger({

@@ -12,9 +19,3 @@ name: 'foo',

type: 'raw',
stream: new AliyunSlsStream({
accessKeyId: process.env.ALIYUN_ACCESS_KEY_ID,
secretAccessKey: process.env.ALIYUN_SECRET_ACCESS_KEY,
endpoint: process.env.ALIYUN_ENDPOINT,
project: process.env.ALIYUN_PROJECT,
logStore: process.env.ALIYUN_LOG_STORE
}),
stream,
reemitErrorEvents: true

@@ -24,6 +25,6 @@ }],

})
t.context = { log }
t.context = { log, stream }
})
test('write logs', async t => {
test('write bunyan logs', async t => {
const { log } = t.context

@@ -37,1 +38,9 @@ log.debug('foobar')

})
test('write logs', async t => {
const { stream } = t.context
stream.write({ from: 'stream' })
await new Promise(resolve => setTimeout(resolve, 2000))
t.pass()
})
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