@logtail/core
Advanced tools
Comparing version 0.4.10 to 0.4.11
import { ILogLevel, ILogtailLog, ILogtailOptions, Context, Middleware, Sync } from "@logtail/types"; | ||
type Message = string | Error; | ||
/** | ||
* Logtail core class for logging to the Logtail.com service | ||
* Logtail core class for logging to the Better Stack service | ||
*/ | ||
@@ -20,3 +20,3 @@ declare class Logtail { | ||
* | ||
* @param sourceToken: string - Private source token for logging to Logtail.com | ||
* @param sourceToken: string - Private source token for logging to Better Stack | ||
* @param options?: ILogtailOptions - Optionally specify Logtail options | ||
@@ -37,3 +37,3 @@ */ | ||
/** | ||
* Number of log entries synced with Logtail.com | ||
* Number of log entries synced with Better Stack | ||
* | ||
@@ -50,3 +50,3 @@ * @returns number | ||
/** | ||
* Log an entry, to be synced with Logtail.com | ||
* Log an entry, to be synced with Better Stack | ||
* | ||
@@ -61,3 +61,3 @@ * @param message: string - Log message | ||
* | ||
* Debug level log, to be synced with Logtail.com | ||
* Debug level log, to be synced with Better Stack | ||
* | ||
@@ -71,3 +71,3 @@ * @param message: string - Log message | ||
* | ||
* Info level log, to be synced with Logtail.com | ||
* Info level log, to be synced with Better Stack | ||
* | ||
@@ -81,3 +81,3 @@ * @param message: string - Log message | ||
* | ||
* Warning level log, to be synced with Logtail.com | ||
* Warning level log, to be synced with Better Stack | ||
* | ||
@@ -91,3 +91,3 @@ * @param message: string - Log message | ||
* | ||
* Warning level log, to be synced with Logtail.com | ||
* Warning level log, to be synced with Better Stack | ||
* | ||
@@ -101,3 +101,3 @@ * @param message: string - Log message | ||
* Sets the sync method - i.e. the final step in the pipeline to get logs | ||
* over to Logtail.com | ||
* over to Better Stack | ||
* | ||
@@ -104,0 +104,0 @@ * @param fn - Pipeline function to use as sync method |
@@ -8,4 +8,4 @@ "use strict"; | ||
// Default sync endpoint (protocol + domain) | ||
endpoint: "https://in.logtail.com", | ||
// Maximum number of logs to sync in a single request to Logtail.com | ||
endpoint: "https://in.logs.betterstack.com", | ||
// Maximum number of logs to sync in a single request to Better Stack | ||
batchSize: 1000, | ||
@@ -41,3 +41,3 @@ // Max interval (in milliseconds) before a batch of logs proceeds to syncing | ||
/** | ||
* Logtail core class for logging to the Logtail.com service | ||
* Logtail core class for logging to the Better Stack service | ||
*/ | ||
@@ -49,3 +49,3 @@ class Logtail { | ||
* | ||
* @param sourceToken: string - Private source token for logging to Logtail.com | ||
* @param sourceToken: string - Private source token for logging to Better Stack | ||
* @param options?: ILogtailOptions - Optionally specify Logtail options | ||
@@ -66,3 +66,3 @@ */ | ||
} | ||
// Store the source token, to use for syncing with Logtail.com | ||
// Store the source token, to use for syncing with Better Stack | ||
this._sourceToken = sourceToken; | ||
@@ -109,3 +109,3 @@ // Merge default and user options | ||
/** | ||
* Number of log entries synced with Logtail.com | ||
* Number of log entries synced with Better Stack | ||
* | ||
@@ -126,3 +126,3 @@ * @returns number | ||
/** | ||
* Log an entry, to be synced with Logtail.com | ||
* Log an entry, to be synced with Better Stack | ||
* | ||
@@ -216,3 +216,3 @@ * @param message: string - Log message | ||
* | ||
* Debug level log, to be synced with Logtail.com | ||
* Debug level log, to be synced with Better Stack | ||
* | ||
@@ -228,3 +228,3 @@ * @param message: string - Log message | ||
* | ||
* Info level log, to be synced with Logtail.com | ||
* Info level log, to be synced with Better Stack | ||
* | ||
@@ -240,3 +240,3 @@ * @param message: string - Log message | ||
* | ||
* Warning level log, to be synced with Logtail.com | ||
* Warning level log, to be synced with Better Stack | ||
* | ||
@@ -252,3 +252,3 @@ * @param message: string - Log message | ||
* | ||
* Warning level log, to be synced with Logtail.com | ||
* Warning level log, to be synced with Better Stack | ||
* | ||
@@ -264,3 +264,3 @@ * @param message: string - Log message | ||
* Sets the sync method - i.e. the final step in the pipeline to get logs | ||
* over to Logtail.com | ||
* over to Better Stack | ||
* | ||
@@ -267,0 +267,0 @@ * @param fn - Pipeline function to use as sync method |
@@ -11,7 +11,7 @@ "use strict"; | ||
const sourceToken = "testing"; | ||
const base = new base_1.default(sourceToken); | ||
const base = new base_1.default(sourceToken, { throwExceptions: true }); | ||
expect(base._sourceToken).toEqual(sourceToken); | ||
}); | ||
it("should throw if a `sync` method is missing", async () => { | ||
const base = new base_1.default("testing"); | ||
const base = new base_1.default("testing", { throwExceptions: true }); | ||
// Expect logging to throw an error, since we're missing a `sync` func | ||
@@ -23,3 +23,3 @@ await expect(base.log("Test")).rejects.toThrowError(/sync/); | ||
const message = "Test"; | ||
const base = new base_1.default("testing"); | ||
const base = new base_1.default("testing", { throwExceptions: true }); | ||
// Add a mock sync method | ||
@@ -35,15 +35,15 @@ base.setSync(async (logs) => logs); | ||
it("should default log count to zero", () => { | ||
const base = new base_1.default("testing"); | ||
const base = new base_1.default("testing", { throwExceptions: true }); | ||
expect(base.logged).toEqual(0); | ||
}); | ||
it("should default synced count to zero", () => { | ||
const base = new base_1.default("testing"); | ||
const base = new base_1.default("testing", { throwExceptions: true }); | ||
expect(base.synced).toEqual(0); | ||
}); | ||
it("should default dropped count to zero", () => { | ||
const base = new base_1.default("testing"); | ||
const base = new base_1.default("testing", { throwExceptions: true }); | ||
expect(base.dropped).toEqual(0); | ||
}); | ||
it("should increment log count on `.log()`", async () => { | ||
const base = new base_1.default("testing"); | ||
const base = new base_1.default("testing", { throwExceptions: true }); | ||
// Add a mock sync method | ||
@@ -56,3 +56,3 @@ base.setSync(async (log) => log); | ||
it("should sync after 500 ms", async () => { | ||
const base = new base_1.default("testing"); | ||
const base = new base_1.default("testing", { throwExceptions: true }); | ||
// Create a sync function that resolves after 500ms | ||
@@ -79,3 +79,7 @@ base.setSync(async (log) => { | ||
// New Base with very long batch interval and size | ||
const base = new base_1.default("testing", { batchInterval: 10000, batchSize: 5 }); | ||
const base = new base_1.default("testing", { | ||
throwExceptions: true, | ||
batchInterval: 10000, | ||
batchSize: 5, | ||
}); | ||
// Create a sync function that resolves after 50ms | ||
@@ -103,3 +107,3 @@ base.setSync(async (log) => { | ||
const firstMessage = "First message"; | ||
const base = new base_1.default("testing"); | ||
const base = new base_1.default("testing", { throwExceptions: true }); | ||
// Add a mock sync method | ||
@@ -119,3 +123,3 @@ base.setSync(async (log) => log); | ||
it("should remove a pipeline function", async () => { | ||
const base = new base_1.default("testing"); | ||
const base = new base_1.default("testing", { throwExceptions: true }); | ||
// Create a pipeline function | ||
@@ -135,3 +139,3 @@ const customPipeline = async (log) => log; | ||
const message = "Test"; | ||
const base = new base_1.default("testing"); | ||
const base = new base_1.default("testing", { throwExceptions: true }); | ||
// Add a mock sync method | ||
@@ -147,3 +151,3 @@ base.setSync(async (log) => log); | ||
const message = "Test"; | ||
const base = new base_1.default("testing"); | ||
const base = new base_1.default("testing", { throwExceptions: true }); | ||
// Add a mock sync method | ||
@@ -159,3 +163,3 @@ base.setSync(async (log) => log); | ||
const message = "Test"; | ||
const base = new base_1.default("testing"); | ||
const base = new base_1.default("testing", { throwExceptions: true }); | ||
// Add a mock sync method | ||
@@ -171,3 +175,3 @@ base.setSync(async (log) => log); | ||
const message = "Test"; | ||
const base = new base_1.default("testing"); | ||
const base = new base_1.default("testing", { throwExceptions: true }); | ||
// Add a mock sync method | ||
@@ -183,3 +187,3 @@ base.setSync(async (log) => log); | ||
const message = "Test"; | ||
const base = new base_1.default("testing"); | ||
const base = new base_1.default("testing", { throwExceptions: true }); | ||
// Add a mock sync method | ||
@@ -196,3 +200,3 @@ base.setSync(async (log) => log); | ||
const e = new Error(message); | ||
const base = new base_1.default("testing"); | ||
const base = new base_1.default("testing", { throwExceptions: true }); | ||
// Add a mock sync method | ||
@@ -211,6 +215,3 @@ base.setSync(async (log) => log); | ||
const e = new Error("Should NOT be ignored!"); | ||
const base = new base_1.default("testing", { | ||
ignoreExceptions: false, | ||
throwExceptions: true, | ||
}); | ||
const base = new base_1.default("testing", { throwExceptions: true }); | ||
// Add a mock sync method which throws an error | ||
@@ -225,5 +226,3 @@ base.setSync(async () => { | ||
const message = "Testing exceptions"; | ||
const base = new base_1.default("testing", { | ||
ignoreExceptions: true, | ||
}); | ||
const base = new base_1.default("testing", { ignoreExceptions: true }); | ||
// Add a mock sync method which throws an error | ||
@@ -241,3 +240,3 @@ base.setSync(async () => { | ||
const message = "Testing logging"; | ||
const base = new base_1.default("testing"); | ||
const base = new base_1.default("testing", { throwExceptions: true }); | ||
// Add a mock sync method which counts sync calls and sent logs | ||
@@ -267,2 +266,3 @@ let syncCount = 0; | ||
const base = new base_1.default("testing", { | ||
throwExceptions: true, | ||
sendLogsToBetterStack: false, | ||
@@ -294,2 +294,3 @@ }); | ||
const base = new base_1.default("testing", { | ||
throwExceptions: true, | ||
sendLogsToConsoleOutput: true, | ||
@@ -332,3 +333,3 @@ batchInterval: 10, | ||
const message = "Testing logging"; | ||
const base = new base_1.default("testing"); | ||
const base = new base_1.default("testing", { throwExceptions: true }); | ||
// Add a mock sync method which resolves after a timeout | ||
@@ -360,2 +361,3 @@ base.setSync(async (logs) => { | ||
const base = new base_1.default("testing", { | ||
throwExceptions: true, | ||
burstProtectionMilliseconds: 100, | ||
@@ -387,2 +389,3 @@ burstProtectionMax: 100, | ||
const base = new base_1.default("testing", { | ||
throwExceptions: true, | ||
burstProtectionMilliseconds: 100, | ||
@@ -417,3 +420,6 @@ burstProtectionMax: 50, | ||
const message = "Testing logging"; | ||
const base = new base_1.default("testing", { burstProtectionMax: 0 }); | ||
const base = new base_1.default("testing", { | ||
throwExceptions: true, | ||
burstProtectionMax: 0, | ||
}); | ||
// Add a mock sync method | ||
@@ -420,0 +426,0 @@ base.setSync(async (logs) => logs); |
import { ILogLevel, ILogtailLog, ILogtailOptions, Context, Middleware, Sync } from "@logtail/types"; | ||
type Message = string | Error; | ||
/** | ||
* Logtail core class for logging to the Logtail.com service | ||
* Logtail core class for logging to the Better Stack service | ||
*/ | ||
@@ -20,3 +20,3 @@ declare class Logtail { | ||
* | ||
* @param sourceToken: string - Private source token for logging to Logtail.com | ||
* @param sourceToken: string - Private source token for logging to Better Stack | ||
* @param options?: ILogtailOptions - Optionally specify Logtail options | ||
@@ -37,3 +37,3 @@ */ | ||
/** | ||
* Number of log entries synced with Logtail.com | ||
* Number of log entries synced with Better Stack | ||
* | ||
@@ -50,3 +50,3 @@ * @returns number | ||
/** | ||
* Log an entry, to be synced with Logtail.com | ||
* Log an entry, to be synced with Better Stack | ||
* | ||
@@ -61,3 +61,3 @@ * @param message: string - Log message | ||
* | ||
* Debug level log, to be synced with Logtail.com | ||
* Debug level log, to be synced with Better Stack | ||
* | ||
@@ -71,3 +71,3 @@ * @param message: string - Log message | ||
* | ||
* Info level log, to be synced with Logtail.com | ||
* Info level log, to be synced with Better Stack | ||
* | ||
@@ -81,3 +81,3 @@ * @param message: string - Log message | ||
* | ||
* Warning level log, to be synced with Logtail.com | ||
* Warning level log, to be synced with Better Stack | ||
* | ||
@@ -91,3 +91,3 @@ * @param message: string - Log message | ||
* | ||
* Warning level log, to be synced with Logtail.com | ||
* Warning level log, to be synced with Better Stack | ||
* | ||
@@ -101,3 +101,3 @@ * @param message: string - Log message | ||
* Sets the sync method - i.e. the final step in the pipeline to get logs | ||
* over to Logtail.com | ||
* over to Better Stack | ||
* | ||
@@ -104,0 +104,0 @@ * @param fn - Pipeline function to use as sync method |
@@ -6,4 +6,4 @@ import { LogLevel, } from "@logtail/types"; | ||
// Default sync endpoint (protocol + domain) | ||
endpoint: "https://in.logtail.com", | ||
// Maximum number of logs to sync in a single request to Logtail.com | ||
endpoint: "https://in.logs.betterstack.com", | ||
// Maximum number of logs to sync in a single request to Better Stack | ||
batchSize: 1000, | ||
@@ -39,3 +39,3 @@ // Max interval (in milliseconds) before a batch of logs proceeds to syncing | ||
/** | ||
* Logtail core class for logging to the Logtail.com service | ||
* Logtail core class for logging to the Better Stack service | ||
*/ | ||
@@ -47,3 +47,3 @@ class Logtail { | ||
* | ||
* @param sourceToken: string - Private source token for logging to Logtail.com | ||
* @param sourceToken: string - Private source token for logging to Better Stack | ||
* @param options?: ILogtailOptions - Optionally specify Logtail options | ||
@@ -64,3 +64,3 @@ */ | ||
} | ||
// Store the source token, to use for syncing with Logtail.com | ||
// Store the source token, to use for syncing with Better Stack | ||
this._sourceToken = sourceToken; | ||
@@ -107,3 +107,3 @@ // Merge default and user options | ||
/** | ||
* Number of log entries synced with Logtail.com | ||
* Number of log entries synced with Better Stack | ||
* | ||
@@ -124,3 +124,3 @@ * @returns number | ||
/** | ||
* Log an entry, to be synced with Logtail.com | ||
* Log an entry, to be synced with Better Stack | ||
* | ||
@@ -214,3 +214,3 @@ * @param message: string - Log message | ||
* | ||
* Debug level log, to be synced with Logtail.com | ||
* Debug level log, to be synced with Better Stack | ||
* | ||
@@ -226,3 +226,3 @@ * @param message: string - Log message | ||
* | ||
* Info level log, to be synced with Logtail.com | ||
* Info level log, to be synced with Better Stack | ||
* | ||
@@ -238,3 +238,3 @@ * @param message: string - Log message | ||
* | ||
* Warning level log, to be synced with Logtail.com | ||
* Warning level log, to be synced with Better Stack | ||
* | ||
@@ -250,3 +250,3 @@ * @param message: string - Log message | ||
* | ||
* Warning level log, to be synced with Logtail.com | ||
* Warning level log, to be synced with Better Stack | ||
* | ||
@@ -262,3 +262,3 @@ * @param message: string - Log message | ||
* Sets the sync method - i.e. the final step in the pipeline to get logs | ||
* over to Logtail.com | ||
* over to Better Stack | ||
* | ||
@@ -265,0 +265,0 @@ * @param fn - Pipeline function to use as sync method |
@@ -6,7 +6,7 @@ import Base from "./base"; | ||
const sourceToken = "testing"; | ||
const base = new Base(sourceToken); | ||
const base = new Base(sourceToken, { throwExceptions: true }); | ||
expect(base._sourceToken).toEqual(sourceToken); | ||
}); | ||
it("should throw if a `sync` method is missing", async () => { | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
// Expect logging to throw an error, since we're missing a `sync` func | ||
@@ -18,3 +18,3 @@ await expect(base.log("Test")).rejects.toThrowError(/sync/); | ||
const message = "Test"; | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
// Add a mock sync method | ||
@@ -30,15 +30,15 @@ base.setSync(async (logs) => logs); | ||
it("should default log count to zero", () => { | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
expect(base.logged).toEqual(0); | ||
}); | ||
it("should default synced count to zero", () => { | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
expect(base.synced).toEqual(0); | ||
}); | ||
it("should default dropped count to zero", () => { | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
expect(base.dropped).toEqual(0); | ||
}); | ||
it("should increment log count on `.log()`", async () => { | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
// Add a mock sync method | ||
@@ -51,3 +51,3 @@ base.setSync(async (log) => log); | ||
it("should sync after 500 ms", async () => { | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
// Create a sync function that resolves after 500ms | ||
@@ -74,3 +74,7 @@ base.setSync(async (log) => { | ||
// New Base with very long batch interval and size | ||
const base = new Base("testing", { batchInterval: 10000, batchSize: 5 }); | ||
const base = new Base("testing", { | ||
throwExceptions: true, | ||
batchInterval: 10000, | ||
batchSize: 5, | ||
}); | ||
// Create a sync function that resolves after 50ms | ||
@@ -98,3 +102,3 @@ base.setSync(async (log) => { | ||
const firstMessage = "First message"; | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
// Add a mock sync method | ||
@@ -114,3 +118,3 @@ base.setSync(async (log) => log); | ||
it("should remove a pipeline function", async () => { | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
// Create a pipeline function | ||
@@ -130,3 +134,3 @@ const customPipeline = async (log) => log; | ||
const message = "Test"; | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
// Add a mock sync method | ||
@@ -142,3 +146,3 @@ base.setSync(async (log) => log); | ||
const message = "Test"; | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
// Add a mock sync method | ||
@@ -154,3 +158,3 @@ base.setSync(async (log) => log); | ||
const message = "Test"; | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
// Add a mock sync method | ||
@@ -166,3 +170,3 @@ base.setSync(async (log) => log); | ||
const message = "Test"; | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
// Add a mock sync method | ||
@@ -178,3 +182,3 @@ base.setSync(async (log) => log); | ||
const message = "Test"; | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
// Add a mock sync method | ||
@@ -191,3 +195,3 @@ base.setSync(async (log) => log); | ||
const e = new Error(message); | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
// Add a mock sync method | ||
@@ -206,6 +210,3 @@ base.setSync(async (log) => log); | ||
const e = new Error("Should NOT be ignored!"); | ||
const base = new Base("testing", { | ||
ignoreExceptions: false, | ||
throwExceptions: true, | ||
}); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
// Add a mock sync method which throws an error | ||
@@ -220,5 +221,3 @@ base.setSync(async () => { | ||
const message = "Testing exceptions"; | ||
const base = new Base("testing", { | ||
ignoreExceptions: true, | ||
}); | ||
const base = new Base("testing", { ignoreExceptions: true }); | ||
// Add a mock sync method which throws an error | ||
@@ -236,3 +235,3 @@ base.setSync(async () => { | ||
const message = "Testing logging"; | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
// Add a mock sync method which counts sync calls and sent logs | ||
@@ -262,2 +261,3 @@ let syncCount = 0; | ||
const base = new Base("testing", { | ||
throwExceptions: true, | ||
sendLogsToBetterStack: false, | ||
@@ -289,2 +289,3 @@ }); | ||
const base = new Base("testing", { | ||
throwExceptions: true, | ||
sendLogsToConsoleOutput: true, | ||
@@ -327,3 +328,3 @@ batchInterval: 10, | ||
const message = "Testing logging"; | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
// Add a mock sync method which resolves after a timeout | ||
@@ -355,2 +356,3 @@ base.setSync(async (logs) => { | ||
const base = new Base("testing", { | ||
throwExceptions: true, | ||
burstProtectionMilliseconds: 100, | ||
@@ -382,2 +384,3 @@ burstProtectionMax: 100, | ||
const base = new Base("testing", { | ||
throwExceptions: true, | ||
burstProtectionMilliseconds: 100, | ||
@@ -412,3 +415,6 @@ burstProtectionMax: 50, | ||
const message = "Testing logging"; | ||
const base = new Base("testing", { burstProtectionMax: 0 }); | ||
const base = new Base("testing", { | ||
throwExceptions: true, | ||
burstProtectionMax: 0, | ||
}); | ||
// Add a mock sync method | ||
@@ -415,0 +421,0 @@ base.setSync(async (logs) => logs); |
# License | ||
Copyright (c) 2021, Logtail | ||
Copyright (c) 2021, Better Stack, Inc. | ||
@@ -5,0 +5,0 @@ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. |
{ | ||
"name": "@logtail/core", | ||
"version": "0.4.10", | ||
"description": "Logtail.com - logging core", | ||
"version": "0.4.11", | ||
"description": "Better Stack logging core (formerly Logtail)", | ||
"keywords": [ | ||
"Better Stack", | ||
"Logtail", | ||
@@ -10,3 +11,3 @@ "logger", | ||
], | ||
"author": "Logtail <hello@logtail.com>", | ||
"author": "Better Stack <hello@betterstack.com>", | ||
"homepage": "https://github.com/logtail/logtail-js/tree/master/packages/core#readme", | ||
@@ -44,6 +45,6 @@ "license": "ISC", | ||
"dependencies": { | ||
"@logtail/tools": "^0.4.10", | ||
"@logtail/types": "^0.4.9" | ||
"@logtail/tools": "^0.4.11", | ||
"@logtail/types": "^0.4.11" | ||
}, | ||
"gitHead": "90a93feb98341eddc7926e0df857d2a2a86777d5" | ||
"gitHead": "5edd3c6501c50c6747811e25622f55a3986a9264" | ||
} |
@@ -22,3 +22,3 @@ # [Better Stack](https://betterstack.com/logs) JavaScript client: Logging core library | ||
For example - you could create a custom logger that implements its own sync method, for getting data over to [Logtail.com](https://logtail.com) | ||
For example - you could create a custom logger that implements its own sync method, for getting data over to [Better Stack](https://logs.betterstack.com) | ||
@@ -30,3 +30,3 @@ ```typescript | ||
class CustomLogger extends Base { | ||
// Constructor must take a Logtail.com source token, and (optional) options | ||
// Constructor must take a Better Stack source token, and (optional) options | ||
public constructor(sourceToken: string, options?: Partial<ILogtailOptions>) { | ||
@@ -51,7 +51,7 @@ // Make sure you pass the source token to the parent constructor! | ||
Logging to Logtail is simple - just call the `.log()` function with a string message: | ||
Logging to Better Stack is simple - just call the `.log()` function with a string message: | ||
```typescript | ||
// Simple log message (defaults to the 'info' log level) | ||
logtail.log("Hello Logtail!"); | ||
logtail.log("Hello Better Stack!"); | ||
@@ -79,6 +79,6 @@ // Or, add custom context keys to pass along with the log | ||
All log levels return a Promise that will resolve once the log has been synced with [Logtail.com](https://logtail.com): | ||
All log levels return a Promise that will resolve once the log has been synced with [Better Stack](https://logs.betterstack.com): | ||
```typescript | ||
// Will resolve when synced with Logtail.com (or reject if there's an error) | ||
// Will resolve when synced with Better Stack (or reject if there's an error) | ||
logtail.log("some log message").then(log => { | ||
@@ -93,3 +93,3 @@ // `log` is the transformed log, after going through middleware | ||
This is useful for augmenting the log prior to syncing with Logtail, or even pushing the log to another service. | ||
This is useful for augmenting the log prior to syncing with Better Stack, or even pushing the log to another service. | ||
@@ -126,3 +126,3 @@ Here's what a middleware function looks like: | ||
Middleware functions run _before_ the final sync to Logtail.com. Pipeline functions should return a `Promise<ILogtailLog>`, making it possible to augment logs with asynchronous data from external sources. | ||
Middleware functions run _before_ the final sync to Better Stack. Pipeline functions should return a `Promise<ILogtailLog>`, making it possible to augment logs with asynchronous data from external sources. | ||
@@ -129,0 +129,0 @@ **Note: If an exception is thrown anywhere in the pipeline chain, the log _won't_ be synced. Wrap an async `try/catch` block around your call to `.log|info|debug|warn|error()` or tack on a `.catch()` to ensure your errors are handled.** |
@@ -7,3 +7,3 @@ import Base from "./base"; | ||
const sourceToken = "testing"; | ||
const base = new Base(sourceToken); | ||
const base = new Base(sourceToken, { throwExceptions: true }); | ||
@@ -14,3 +14,3 @@ expect((base as any)._sourceToken).toEqual(sourceToken); | ||
it("should throw if a `sync` method is missing", async () => { | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
@@ -24,3 +24,3 @@ // Expect logging to throw an error, since we're missing a `sync` func | ||
const message = "Test"; | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
@@ -41,3 +41,3 @@ // Add a mock sync method | ||
it("should default log count to zero", () => { | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
@@ -48,3 +48,3 @@ expect(base.logged).toEqual(0); | ||
it("should default synced count to zero", () => { | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
@@ -55,3 +55,3 @@ expect(base.synced).toEqual(0); | ||
it("should default dropped count to zero", () => { | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
@@ -62,3 +62,3 @@ expect(base.dropped).toEqual(0); | ||
it("should increment log count on `.log()`", async () => { | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
@@ -75,3 +75,3 @@ // Add a mock sync method | ||
it("should sync after 500 ms", async () => { | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
@@ -105,3 +105,7 @@ // Create a sync function that resolves after 500ms | ||
// New Base with very long batch interval and size | ||
const base = new Base("testing", { batchInterval: 10000, batchSize: 5 }); | ||
const base = new Base("testing", { | ||
throwExceptions: true, | ||
batchInterval: 10000, | ||
batchSize: 5, | ||
}); | ||
@@ -136,3 +140,3 @@ // Create a sync function that resolves after 50ms | ||
const firstMessage = "First message"; | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
@@ -161,3 +165,3 @@ // Add a mock sync method | ||
it("should remove a pipeline function", async () => { | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
@@ -183,3 +187,3 @@ // Create a pipeline function | ||
const message = "Test"; | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
@@ -199,3 +203,3 @@ // Add a mock sync method | ||
const message = "Test"; | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
@@ -215,3 +219,3 @@ // Add a mock sync method | ||
const message = "Test"; | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
@@ -231,3 +235,3 @@ // Add a mock sync method | ||
const message = "Test"; | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
@@ -247,3 +251,3 @@ // Add a mock sync method | ||
const message = "Test"; | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
@@ -264,3 +268,3 @@ // Add a mock sync method | ||
const e = new Error(message); | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
@@ -284,6 +288,3 @@ // Add a mock sync method | ||
const e = new Error("Should NOT be ignored!"); | ||
const base = new Base("testing", { | ||
ignoreExceptions: false, | ||
throwExceptions: true, | ||
}); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
@@ -301,5 +302,3 @@ // Add a mock sync method which throws an error | ||
const message = "Testing exceptions"; | ||
const base = new Base("testing", { | ||
ignoreExceptions: true, | ||
}); | ||
const base = new Base("testing", { ignoreExceptions: true }); | ||
@@ -321,3 +320,3 @@ // Add a mock sync method which throws an error | ||
const message = "Testing logging"; | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
@@ -351,2 +350,3 @@ // Add a mock sync method which counts sync calls and sent logs | ||
const base = new Base("testing", { | ||
throwExceptions: true, | ||
sendLogsToBetterStack: false, | ||
@@ -382,2 +382,3 @@ }); | ||
const base = new Base("testing", { | ||
throwExceptions: true, | ||
sendLogsToConsoleOutput: true, | ||
@@ -433,3 +434,3 @@ batchInterval: 10, | ||
const message = "Testing logging"; | ||
const base = new Base("testing"); | ||
const base = new Base("testing", { throwExceptions: true }); | ||
@@ -471,2 +472,3 @@ // Add a mock sync method which resolves after a timeout | ||
const base = new Base("testing", { | ||
throwExceptions: true, | ||
burstProtectionMilliseconds: 100, | ||
@@ -506,2 +508,3 @@ burstProtectionMax: 100, | ||
const base = new Base("testing", { | ||
throwExceptions: true, | ||
burstProtectionMilliseconds: 100, | ||
@@ -548,3 +551,6 @@ burstProtectionMax: 50, | ||
const message = "Testing logging"; | ||
const base = new Base("testing", { burstProtectionMax: 0 }); | ||
const base = new Base("testing", { | ||
throwExceptions: true, | ||
burstProtectionMax: 0, | ||
}); | ||
@@ -551,0 +557,0 @@ // Add a mock sync method |
@@ -18,5 +18,5 @@ import { | ||
// Default sync endpoint (protocol + domain) | ||
endpoint: "https://in.logtail.com", | ||
endpoint: "https://in.logs.betterstack.com", | ||
// Maximum number of logs to sync in a single request to Logtail.com | ||
// Maximum number of logs to sync in a single request to Better Stack | ||
batchSize: 1000, | ||
@@ -66,3 +66,3 @@ | ||
/** | ||
* Logtail core class for logging to the Logtail.com service | ||
* Logtail core class for logging to the Better Stack service | ||
*/ | ||
@@ -105,3 +105,3 @@ class Logtail { | ||
* | ||
* @param sourceToken: string - Private source token for logging to Logtail.com | ||
* @param sourceToken: string - Private source token for logging to Better Stack | ||
* @param options?: ILogtailOptions - Optionally specify Logtail options | ||
@@ -115,3 +115,3 @@ */ | ||
// Store the source token, to use for syncing with Logtail.com | ||
// Store the source token, to use for syncing with Better Stack | ||
this._sourceToken = sourceToken; | ||
@@ -179,3 +179,3 @@ | ||
/** | ||
* Number of log entries synced with Logtail.com | ||
* Number of log entries synced with Better Stack | ||
* | ||
@@ -198,3 +198,3 @@ * @returns number | ||
/** | ||
* Log an entry, to be synced with Logtail.com | ||
* Log an entry, to be synced with Better Stack | ||
* | ||
@@ -317,3 +317,3 @@ * @param message: string - Log message | ||
* | ||
* Debug level log, to be synced with Logtail.com | ||
* Debug level log, to be synced with Better Stack | ||
* | ||
@@ -333,3 +333,3 @@ * @param message: string - Log message | ||
* | ||
* Info level log, to be synced with Logtail.com | ||
* Info level log, to be synced with Better Stack | ||
* | ||
@@ -349,3 +349,3 @@ * @param message: string - Log message | ||
* | ||
* Warning level log, to be synced with Logtail.com | ||
* Warning level log, to be synced with Better Stack | ||
* | ||
@@ -365,3 +365,3 @@ * @param message: string - Log message | ||
* | ||
* Warning level log, to be synced with Logtail.com | ||
* Warning level log, to be synced with Better Stack | ||
* | ||
@@ -381,3 +381,3 @@ * @param message: string - Log message | ||
* Sets the sync method - i.e. the final step in the pipeline to get logs | ||
* over to Logtail.com | ||
* over to Better Stack | ||
* | ||
@@ -384,0 +384,0 @@ * @param fn - Pipeline function to use as sync method |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
140978
2445
Updated@logtail/tools@^0.4.11
Updated@logtail/types@^0.4.11