Skip to content

Commit 41b9624

Browse files
committed
make example project work with cloud ingesting
1 parent 3f4d347 commit 41b9624

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

example-project/README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ npm install
1515
To run the example application, simply run the following command:
1616

1717
```bash
18-
node index.js <source-token>
18+
node index.js <source-token> <ingesting-host>
1919
```
2020

21-
_Don't forget to replace <source-token> with your actual source token which you can find by going to logs.betterstack.com -> sources -> edit._
21+
_Don't forget to replace <source-token> with your actual source token which you can find by going to telemetry.betterstack.com -> sources -> configure._
22+
23+
The `<ingesting-host>` variable is optional. It defaults to `https://in.logs.betterstack.com` but you can provide a different host by heading to **[Sources](https://telemetry.betterstack.com/team/0/sources) -> Configure** in Better Stack.
2224

2325
You should see the following output:
2426

@@ -190,7 +192,9 @@ const { Logtail } = require("@logtail/koa");
190192
const koa = new Koa();
191193

192194
// Create a new Better Stack Logs client
193-
const logtail = new Logtail("<source-token>");
195+
const logtail = new Logtail("<source-token>", {
196+
endpoint: "<ingesting-host>", // optional
197+
});
194198

195199
// Attach Koa to enable HTTP request logging
196200
logtail.attach(koa);
@@ -231,7 +235,9 @@ const { Logtail } = require("@logtail/node");
231235
const { LogtailTransport } = require("@logtail/winston");
232236

233237
// Create a Better Stack Logs client
234-
const logtail = new Logtail("<source-token>");
238+
const logtail = new Logtail("<source-token>", {
239+
endpoint: "<ingesting-host>", // optional
240+
});
235241

236242
// Create a Winston logger - passing in the Logtail transport
237243
const logger = winston.createLogger({
@@ -262,7 +268,9 @@ const { Logtail } = require("@logtail/node");
262268
const { LogtailStream } = require("@logtail/bunyan");
263269

264270
// Create a Better Stack Logs client
265-
const logtail = new Logtail("logtail-source-token");
271+
const logtail = new Logtail("logtail-source-token", {
272+
endpoint: "<ingesting-host>", // optional
273+
});
266274

267275
// Create a Bunyan logger - passing in the Logtail stream
268276
const logger = bunyan.createLogger({

example-project/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@ const { Node: Logtail } = require("@logtail/js");
1313
// In frontend code use the following:
1414
// import { Browser as Logtail } from "@logtail/js";
1515

16+
// Set ingesting host using command line argument or omit to use the default
17+
const endpoint = process.argv[3] || "https://in.logs.betterstack.com";
18+
1619
// Create a logger from a Logtail class
17-
const logger = new Logtail(process.argv[2], { sendLogsToConsoleOutput: true });
20+
const logger = new Logtail(process.argv[2], {
21+
sendLogsToConsoleOutput: true,
22+
endpoint,
23+
});
1824

1925
// Usage
2026

0 commit comments

Comments
 (0)