Skip to content

Commit

Permalink
Merge pull request #101 from JaniAnttonen/development
Browse files Browse the repository at this point in the history
Merge new patches to master
  • Loading branch information
JaniAnttonen authored Feb 11, 2022
2 parents ed2da3d + 41902b8 commit 8bb6494
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 37 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish to NPM
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
registry-url: https://registry.npmjs.org
- name: Check node_modules cache
uses: actions/cache@v2
id: yarn-cache
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
- name: Test
run: yarn test --ci --coverage
- name: Version
run: yarn version --new-version "${GITHUB_REF:11}" --no-git-tag-version
- name: Publish
run: yarn publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ LokiTransport() takes a Javascript object as an input. These are the options tha
| `batching` | If batching is not used, the logs are sent as they come | true | true |
| `clearOnError` | Discard any logs that result in an error during transport | true | false |
| `replaceTimestamp` | Replace any log timestamps with Date.now() | true | false |
| `labels` | custom labels, key-value pairs | { module: 'http' } | null |
| `format` | winston format (https://github.com/winstonjs/winston#formats) | simple() | null |
| `labels` | custom labels, key-value pairs | { module: 'http' } | undefined |
| `format` | winston format (https://github.com/winstonjs/winston#formats) | simple() | undefined |
| `gracefulShutdown` | Enable/disable graceful shutdown (wait for any unsent batches) | false | true |
| `timeout` | timeout for requests to grafana loki in ms | 30000 | null |
| `basicAuth` | basic authentication credentials to access Loki over HTTP | username:password | null |
| `timeout` | timeout for requests to grafana loki in ms | 30000 | undefined |
| `basicAuth` | basic authentication credentials to access Loki over HTTP | username:password | undefined |
| `onConnectionError`| Loki error connection handler | (err) => console.error(err) | undefined |

### Example
With default formatting:
Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ declare interface LokiTransportOptions extends TransportStream.TransportStreamOp
batching?: boolean;
labels?: object;
clearOnError?: boolean,
replaceOnError?: boolean,
replaceTimestamp?: boolean,
gracefulShutdown?: boolean,
timeout?: number,
onConnectionError?(error: unknown): void
}

declare class LokiTransport extends TransportStream {
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class LokiTransport extends Transport {
json: options.json,
batching: options.batching !== false,
clearOnError: options.clearOnError,
replaceOnError: options.replaceOnError,
onConnectionError: options.onConnectionError,
replaceTimestamp: options.replaceTimestamp,
gracefulShutdown: options.gracefulShutdown !== false,
timeout: options.timeout
Expand Down
38 changes: 7 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/batcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ class Batcher {
.catch(err => {
// Clear the batch on error if enabled
this.options.clearOnError && this.clearBatch()

this.options.onConnectionError !== undefined && this.options.onConnectionError(err)

reject(err)
})
}
Expand Down

0 comments on commit 8bb6494

Please sign in to comment.