Skip to content

Commit

Permalink
Merge pull request #18 from JaniAnttonen/feat/1.0.0-support
Browse files Browse the repository at this point in the history
Verify to work with the first major version of Loki
  • Loading branch information
JaniAnttonen authored Jan 8, 2020
2 parents 7f5811e + d5fb14c commit 16b5a64
Show file tree
Hide file tree
Showing 17 changed files with 4,257 additions and 1,691 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

A Grafana Loki transport for the nodejs logging library Winston.

__NOTE: Latest version only guaranteed to work with the latest version of Grafana Loki. Make sure to update Loki if you have updated this package__

## Usage
This Winston transport is used similarly to other Winston transports. Require winston and define a new LokiTransport() inside its options when creating it.

Expand All @@ -27,6 +25,7 @@ LokiTransport() takes a Javascript object as an input. These are the options tha
| `format` | winston format (https://github.com/winstonjs/winston#formats) | simple() | null |

### Example
With default formatting:
```js
const { createLogger, transports } = require("winston");
const LokiTransport = require("winston-loki");
Expand All @@ -41,8 +40,15 @@ const options = {
};
const logger = createLogger(options);
```
TODO: Add custom formatting example

## Developing
### Requirements
Running a local Loki for testing is probably required, and the easiest way to do that is to follow this guide: https://github.com/grafana/loki/tree/master/production#run-locally-using-docker. After that, Grafana Loki instance is available at `http://localhost:3100`, with a Grafana instance running at `http://localhost:3000`. Username `admin`, password `admin`. Add the Loki source with the URL `http://loki:3100`, and the explorer should work.

Refer to https://github.com/grafana/loki/blob/master/docs/api.md for documentation about the available endpoints, data formats etc.

### Example
```sh
npm install
npm link
Expand All @@ -51,16 +57,11 @@ npm link winston-loki
npm install
```
And you should have a working, requirable winston-loki package under your project's node_modules.

Refer to https://github.com/grafana/loki/blob/master/docs/api.md for documentation about the available endpoints, data formats etc.

Grafana Loki *doesn't have any official releases or version numbers* as of now, so if the API is changed, it's going to be fun, but it's working as of now.
After the link has been established, any changes to winston-loki should show on rerun of the software that uses it.

### Run tests
```sh
npm test
```

Write new ones under `/test`

TODO: Remove *got* dependency
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "winston-loki",
"version": "4.0.2",
"version": "5.0.0",
"description": "A Winston transport for Grafana Loki",
"keywords": [
"winston",
Expand Down Expand Up @@ -29,7 +29,8 @@
"jest": true
},
"ignore": [
"test/coverage"
"test/coverage",
"src/proto/index.js"
]
},
"jest": {
Expand Down
2 changes: 1 addition & 1 deletion src/batcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class Batcher {
reqBody = JSON.stringify({ streams: [logEntry] })
} else {
// Stringify the JSON ready for transport
reqBody = JSON.stringify(reqBody)
reqBody = JSON.stringify(this.batch)
}
} else {
try {
Expand Down
Loading

0 comments on commit 16b5a64

Please sign in to comment.