Skip to content

Commit

Permalink
Add logging option for v2.0.3 (#93)
Browse files Browse the repository at this point in the history
* Add verbose logging

* Update README.md

* Update README.md

* Add test workflow

* update test workflow

* verbose => debug

* verbose => debug

* remove verbose

* version => 2.0.3
  • Loading branch information
yotamloe authored Aug 31, 2021
1 parent cff010e commit a97c46c
Show file tree
Hide file tree
Showing 5 changed files with 7,750 additions and 21 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/test-nodejs-8-16.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js test

on:
pull_request:
branches: [ development, master, main ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [8.x, 10.x, 12.x, 14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm install --save request
- run: npm run test
6 changes: 3 additions & 3 deletions lib/logzio-nodejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const stringifySafe = require('json-stringify-safe');
const assign = require('lodash.assign');
const dgram = require('dgram');
const zlib = require('zlib');

const nanoSecDigits = 9;

exports.version = require('../package.json').version;
Expand Down Expand Up @@ -281,6 +282,7 @@ class LogzioLogger {
}

_tryToSend(options, bulk) {
this._debug(`Sending bulk of ${bulk.msgs.length} logs`)
return request.post(options)
.then(() => {
this._debug(`Bulk #${bulk.id} - sent successfully`);
Expand All @@ -300,14 +302,12 @@ class LogzioLogger {

return this._tryAgainIn(sleepTimeMs, bulk);
}

if (err.statusCode !== 200) {
return this.callback(new Error(`There was a problem with the request.\nResponse: ${err.statusCode}: ${err.message}`), bulk);
}

return this.callback(err, bulk);
});
}
}
}

const createLogger = (options) => {
Expand Down
Loading

0 comments on commit a97c46c

Please sign in to comment.