@logtail/core
Advanced tools
Comparing version 0.1.1 to 0.1.7
@@ -7,3 +7,3 @@ import { ILogtailLog, ILogtailOptions, Context, LogLevel, Middleware, Sync } from "@logtail/types"; | ||
declare class Logtail { | ||
protected _accessToken: string; | ||
protected _sourceToken: string; | ||
protected _options: ILogtailOptions; | ||
@@ -18,6 +18,6 @@ protected _batch: any; | ||
* | ||
* @param accessToken: string - Private source access token for logging to Logtail.com | ||
* @param sourceToken: string - Private source token for logging to Logtail.com | ||
* @param options?: ILogtailOptions - Optionally specify Logtail options | ||
*/ | ||
constructor(accessToken: string, options?: Partial<ILogtailOptions>); | ||
constructor(sourceToken: string, options?: Partial<ILogtailOptions>); | ||
private getContextFromError; | ||
@@ -24,0 +24,0 @@ /** |
@@ -26,6 +26,6 @@ "use strict"; | ||
* | ||
* @param accessToken: string - Private source access token for logging to Logtail.com | ||
* @param sourceToken: string - Private source token for logging to Logtail.com | ||
* @param options?: ILogtailOptions - Optionally specify Logtail options | ||
*/ | ||
constructor(accessToken, options) { | ||
constructor(sourceToken, options) { | ||
// Middleware | ||
@@ -37,8 +37,8 @@ this._middleware = []; | ||
this._countSynced = 0; | ||
// First, check we have a valid source access token | ||
if (typeof accessToken !== "string" || accessToken === "") { | ||
throw new Error("Logtail source access token missing"); | ||
// First, check we have a valid source token | ||
if (typeof sourceToken !== "string" || sourceToken === "") { | ||
throw new Error("Logtail source token missing"); | ||
} | ||
// Store the source access token, to use for syncing with Logtail.com | ||
this._accessToken = accessToken; | ||
// Store the source token, to use for syncing with Logtail.com | ||
this._sourceToken = sourceToken; | ||
// Merge default and user options | ||
@@ -45,0 +45,0 @@ this._options = Object.assign(Object.assign({}, defaultOptions), options); |
@@ -9,6 +9,6 @@ "use strict"; | ||
describe("base class tests", () => { | ||
it("should initialize with access token", () => { | ||
const accessToken = "testing"; | ||
const base = new base_1.default(accessToken); | ||
expect(base._accessToken).toEqual(accessToken); | ||
it("should initialize with source token", () => { | ||
const sourceToken = "testing"; | ||
const base = new base_1.default(sourceToken); | ||
expect(base._sourceToken).toEqual(sourceToken); | ||
}); | ||
@@ -15,0 +15,0 @@ it("should throw if a `sync` method is missing", async () => { |
@@ -7,3 +7,3 @@ import { ILogtailLog, ILogtailOptions, Context, LogLevel, Middleware, Sync } from "@logtail/types"; | ||
declare class Logtail { | ||
protected _accessToken: string; | ||
protected _sourceToken: string; | ||
protected _options: ILogtailOptions; | ||
@@ -18,6 +18,6 @@ protected _batch: any; | ||
* | ||
* @param accessToken: string - Private source access token for logging to Logtail.com | ||
* @param sourceToken: string - Private source token for logging to Logtail.com | ||
* @param options?: ILogtailOptions - Optionally specify Logtail options | ||
*/ | ||
constructor(accessToken: string, options?: Partial<ILogtailOptions>); | ||
constructor(sourceToken: string, options?: Partial<ILogtailOptions>); | ||
private getContextFromError; | ||
@@ -24,0 +24,0 @@ /** |
@@ -24,6 +24,6 @@ import { LogLevel } from "@logtail/types"; | ||
* | ||
* @param accessToken: string - Private source access token for logging to Logtail.com | ||
* @param sourceToken: string - Private source token for logging to Logtail.com | ||
* @param options?: ILogtailOptions - Optionally specify Logtail options | ||
*/ | ||
constructor(accessToken, options) { | ||
constructor(sourceToken, options) { | ||
// Middleware | ||
@@ -35,8 +35,8 @@ this._middleware = []; | ||
this._countSynced = 0; | ||
// First, check we have a valid source access token | ||
if (typeof accessToken !== "string" || accessToken === "") { | ||
throw new Error("Logtail source access token missing"); | ||
// First, check we have a valid source token | ||
if (typeof sourceToken !== "string" || sourceToken === "") { | ||
throw new Error("Logtail source token missing"); | ||
} | ||
// Store the source access token, to use for syncing with Logtail.com | ||
this._accessToken = accessToken; | ||
// Store the source token, to use for syncing with Logtail.com | ||
this._sourceToken = sourceToken; | ||
// Merge default and user options | ||
@@ -43,0 +43,0 @@ this._options = Object.assign(Object.assign({}, defaultOptions), options); |
import Base from "./base"; | ||
import { LogLevel } from "@logtail/types"; | ||
describe("base class tests", () => { | ||
it("should initialize with access token", () => { | ||
const accessToken = "testing"; | ||
const base = new Base(accessToken); | ||
expect(base._accessToken).toEqual(accessToken); | ||
it("should initialize with source token", () => { | ||
const sourceToken = "testing"; | ||
const base = new Base(sourceToken); | ||
expect(base._sourceToken).toEqual(sourceToken); | ||
}); | ||
@@ -9,0 +9,0 @@ it("should throw if a `sync` method is missing", async () => { |
{ | ||
"name": "@logtail/core", | ||
"version": "0.1.1", | ||
"version": "0.1.7", | ||
"description": "Logtail.com - logging core", | ||
@@ -43,6 +43,6 @@ "keywords": [ | ||
"dependencies": { | ||
"@logtail/tools": "^0.1.1", | ||
"@logtail/tools": "^0.1.7", | ||
"@logtail/types": "^0.1.1" | ||
}, | ||
"gitHead": "22d162d9ffdd4b6a4f0cd69de4425ae40715c6e4" | ||
"gitHead": "d98b9f8ca83715e676af0b0411c906a108c4dd74" | ||
} |
@@ -26,13 +26,13 @@ # 🪵 Logtail - logging core | ||
class CustomLogger extends Base { | ||
// Constructor must take a Logtail.com access token, and (optional) options | ||
// Constructor must take a Logtail.com source token, and (optional) options | ||
public constructor( | ||
accessToken: string, | ||
sourceToken: string, | ||
options?: Partial<ILogtailOptions> | ||
) { | ||
// Make sure you pass the source access token to the parent constructor! | ||
super(accessToken, options); | ||
// Make sure you pass the source token to the parent constructor! | ||
super(sourceToken, options); | ||
// Create a custom sync method | ||
this.setSync(async (logs: ILogtailLog[]) => { | ||
// Sync the `log` somehow ... `this._accessToken` contains your Logtail source access token | ||
// Sync the `log` somehow ... `this._sourceToken` contains your Logtail source token | ||
@@ -39,0 +39,0 @@ // .... |
@@ -5,7 +5,7 @@ import Base from "./base"; | ||
describe("base class tests", () => { | ||
it("should initialize with access token", () => { | ||
const accessToken = "testing"; | ||
const base = new Base(accessToken); | ||
it("should initialize with source token", () => { | ||
const sourceToken = "testing"; | ||
const base = new Base(sourceToken); | ||
expect((base as any)._accessToken).toEqual(accessToken); | ||
expect((base as any)._sourceToken).toEqual(sourceToken); | ||
}); | ||
@@ -12,0 +12,0 @@ |
@@ -36,4 +36,4 @@ import { | ||
class Logtail { | ||
// Logtail source access token | ||
protected _accessToken: string; | ||
// Logtail source token | ||
protected _sourceToken: string; | ||
@@ -63,16 +63,16 @@ // Logtail library options | ||
* | ||
* @param accessToken: string - Private source access token for logging to Logtail.com | ||
* @param sourceToken: string - Private source token for logging to Logtail.com | ||
* @param options?: ILogtailOptions - Optionally specify Logtail options | ||
*/ | ||
public constructor( | ||
accessToken: string, | ||
sourceToken: string, | ||
options?: Partial<ILogtailOptions> | ||
) { | ||
// First, check we have a valid source access token | ||
if (typeof accessToken !== "string" || accessToken === "") { | ||
throw new Error("Logtail source access token missing"); | ||
// First, check we have a valid source token | ||
if (typeof sourceToken !== "string" || sourceToken === "") { | ||
throw new Error("Logtail source token missing"); | ||
} | ||
// Store the source access token, to use for syncing with Logtail.com | ||
this._accessToken = accessToken; | ||
// Store the source token, to use for syncing with Logtail.com | ||
this._sourceToken = sourceToken; | ||
@@ -79,0 +79,0 @@ // Merge default and user options |
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
78443
Updated@logtail/tools@^0.1.7