Skip to content

Commit da16e04

Browse files
authored
Merge pull request #56 from datalust/dev
4.0.0
2 parents 7fe49e7 + 5aa4328 commit da16e04

18 files changed

Lines changed: 552 additions & 311 deletions

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ dev ]
6+
pull_request:
7+
branches: [ dev ]
8+
9+
jobs:
10+
test-seq:
11+
name: Build and Test
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
node-version: [18.x, 20.x, 22.x]
17+
18+
services:
19+
seq:
20+
image: datalust/seq:latest
21+
ports:
22+
- 5341:80
23+
- 5342:5342
24+
env:
25+
ACCEPT_EULA: Y
26+
SEQ_FIRSTRUN_NOAUTHENTICATION: True
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
- name: Use Node.js ${{ matrix.node-version }}
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: ${{ matrix.node-version }}
34+
- run: npm ci
35+
- run: npm run build
36+
- run: npm test
37+
- run: npm run test:integration
38+
- run: cd example && npm link && node example.js

.github/workflows/node.js.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/npm-publish.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3-
41
name: Publish
52

63
on:
@@ -31,4 +28,4 @@ jobs:
3128
- run: npm ci
3229
- run: npm publish
3330
env:
34-
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
31+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ logs
33
*.log
44
npm-debug.log*
55

6+
# Build output
7+
/dist
8+
69
# Runtime data
710
pids
811
*.pid

.vscode/launch.json

Lines changed: 0 additions & 62 deletions
This file was deleted.

README.md

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,69 @@
22

33
A stream to send [Pino](https://github.com/pinojs/pino) events to [Seq](https://datalust.co/seq). Tested with Node.js versions 18.x and up.
44

5+
**Now written in TypeScript** with automatic type definitions and full ES Module support!
6+
7+
## Installation
8+
9+
```bash
10+
npm install pino-seq
11+
```
12+
13+
## Usage
14+
515
Use the `createStream()` method to create a Pino stream configuration, passing `serverUrl`, `apiKey` and batching parameters.
616

7-
```js
17+
This example works in both JavaScript and TypeScript projects:
18+
19+
```javascript
820
import pino from 'pino';
9-
import pinoToSeq from 'pino-seq';
21+
import { createStream } from 'pino-seq';
1022

11-
let stream = pinoToSeq.createStream({ serverUrl: 'http://localhost:5341' });
12-
let logger = pino({ name: 'pino-seq example' }, stream);
23+
// Create a stream to Seq
24+
const stream = createStream({
25+
serverUrl: 'http://localhost:5341',
26+
apiKey: 'your-api-key' // optional
27+
});
1328

29+
// Create a Pino logger
30+
const logger = pino({ name: 'pino-seq example' }, stream);
31+
32+
// Log some messages
1433
logger.info('Hello Seq, from Pino');
1534

16-
let frLogger = logger.child({ lang: 'fr' });
35+
// Child loggers work too
36+
const frLogger = logger.child({ lang: 'fr' });
1737
frLogger.warn('au reviour');
38+
39+
// Flush logs before exit
40+
await stream.flush();
1841
```
1942

20-
### Acknowledgements
43+
For TypeScript projects with explicit typing:
44+
45+
```typescript
46+
import { createStream, PinoSeqStreamConfig } from 'pino-seq';
47+
48+
const config: PinoSeqStreamConfig = {
49+
serverUrl: 'http://localhost:5341',
50+
// ... see Configuration section below for all options
51+
};
52+
const stream = createStream(config);
53+
```
54+
55+
## Configuration
56+
57+
The `createStream()` function accepts a configuration object with the following properties:
58+
59+
- `serverUrl` (string): The URL of your Seq server
60+
- `apiKey` (string, optional): API key for authentication
61+
- `logOtherAs` (string, optional): Log level for unstructured messages ('Verbose', 'Debug', 'Information', 'Warning', 'Error', 'Fatal')
62+
- `additionalProperties` (object, optional): Additional properties to add to all log events
63+
- `maxBatchingTime` (number, optional): Maximum time in milliseconds to wait before sending a batch
64+
- `eventSizeLimit` (number, optional): Maximum size of a single event
65+
- `batchSizeLimit` (number, optional): Maximum size of a batch
66+
- `onError` (function, optional): Error handler callback
67+
68+
## Acknowledgements
2169

2270
Originally by Simi Hartstein and published as `simihartstein/pino-seq`; maintainership transferred to Datalust at version 0.5.

example/example.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1-
"use strict";
1+
// This example works in both JavaScript and TypeScript projects
2+
// For TypeScript: rename to .ts or use as-is (types will be inferred)
23

34
import pino from 'pino';
4-
import pinoToSeq from '../index.js';
5+
import { createStream } from 'pino-seq';
56

6-
let stream = pinoToSeq.createStream({serverUrl: "http://localhost:5341"});
7-
let logger = pino({name: "pino-seq example"}, stream);
7+
// Create a stream to Seq
8+
const stream = createStream({
9+
serverUrl: 'http://localhost:5341',
10+
apiKey: 'your-api-key' // optional
11+
});
812

9-
logger.info("Hello Seq, from Pino");
13+
// Create a Pino logger
14+
const logger = pino({ name: 'pino-seq example' }, stream);
1015

11-
let frLogger = logger.child({lang: "fr"});
12-
frLogger.warn("au reviour");
16+
// Log some messages
17+
logger.info('Hello Seq, from Pino');
18+
19+
// Child loggers work too
20+
const frLogger = logger.child({ lang: 'fr' });
21+
frLogger.warn('au reviour');
22+
23+
// Flush logs before exit
24+
await stream.flush();

example/example.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

index.d.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

index.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)