New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@timberio/core

Package Overview
Dependencies
Maintainers
5
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@timberio/core - npm Package Compare versions

Comparing version 0.31.0 to 0.32.0

22

dist/cjs/base.js

@@ -14,3 +14,5 @@ "use strict";

// Maximum number of sync requests to make concurrently
syncMax: 5
syncMax: 5,
// If true, errors/failed logs should be ignored
ignoreExceptions: false,
};

@@ -58,3 +60,3 @@ /**

return {
stack: e.stack
stack: e.stack,
};

@@ -114,6 +116,14 @@ }

const transformedLog = await this._middleware.reduceRight((fn, pipedLog) => fn.then(pipedLog), Promise.resolve(log));
// Push the log through the batcher, and sync
await this._batch(transformedLog);
// Increment sync count
this._countSynced++;
try {
// Push the log through the batcher, and sync
await this._batch(transformedLog);
// Increment sync count
this._countSynced++;
}
catch (e) {
// Catch any errors - re-throw if `ignoreExceptions` == false
if (!this._options.ignoreExceptions) {
throw e;
}
}
// Return the resulting log

@@ -120,0 +130,0 @@ return transformedLog;

@@ -166,5 +166,31 @@ "use strict";

// Context should contain a stack trace
expect(log.context.stack).toBe(e.stack);
expect(log.stack).toBe(e.stack);
});
it("should not ignore exceptions by default", async () => {
// Fixtures
const message = "Testing exceptions";
const e = new Error("Should NOT be ignored!");
const base = new base_1.default("testing");
// Add a mock sync method which throws an error
base.setSync(async () => {
throw e;
});
expect(base.info(message)).rejects.toEqual(e);
});
it("should ignore exceptions if `ignoreExceptions` opt == true", async () => {
// Fixtures
const message = "Testing exceptions";
const base = new base_1.default("testing", {
ignoreExceptions: true,
});
// Add a mock sync method which throws an error
base.setSync(async () => {
throw new Error("Should be ignored!");
});
// Log - shouldn't throw!
const log = await base.info(message);
// Should return the log, even though there was an error
expect(log.message).toBe(message);
});
});
//# sourceMappingURL=base.test.js.map

@@ -1,2 +0,2 @@

import { LogLevel } from "@timberio/types";
import { LogLevel, } from "@timberio/types";
import { makeBatch, makeThrottle } from "@timberio/tools";

@@ -12,3 +12,5 @@ // Set default options for Timber

// Maximum number of sync requests to make concurrently
syncMax: 5
syncMax: 5,
// If true, errors/failed logs should be ignored
ignoreExceptions: false,
};

@@ -56,3 +58,3 @@ /**

return {
stack: e.stack
stack: e.stack,
};

@@ -112,6 +114,14 @@ }

const transformedLog = await this._middleware.reduceRight((fn, pipedLog) => fn.then(pipedLog), Promise.resolve(log));
// Push the log through the batcher, and sync
await this._batch(transformedLog);
// Increment sync count
this._countSynced++;
try {
// Push the log through the batcher, and sync
await this._batch(transformedLog);
// Increment sync count
this._countSynced++;
}
catch (e) {
// Catch any errors - re-throw if `ignoreExceptions` == false
if (!this._options.ignoreExceptions) {
throw e;
}
}
// Return the resulting log

@@ -118,0 +128,0 @@ return transformedLog;

@@ -161,5 +161,31 @@ import Base from "./base";

// Context should contain a stack trace
expect(log.context.stack).toBe(e.stack);
expect(log.stack).toBe(e.stack);
});
it("should not ignore exceptions by default", async () => {
// Fixtures
const message = "Testing exceptions";
const e = new Error("Should NOT be ignored!");
const base = new Base("testing");
// Add a mock sync method which throws an error
base.setSync(async () => {
throw e;
});
expect(base.info(message)).rejects.toEqual(e);
});
it("should ignore exceptions if `ignoreExceptions` opt == true", async () => {
// Fixtures
const message = "Testing exceptions";
const base = new Base("testing", {
ignoreExceptions: true,
});
// Add a mock sync method which throws an error
base.setSync(async () => {
throw new Error("Should be ignored!");
});
// Log - shouldn't throw!
const log = await base.info(message);
// Should return the log, even though there was an error
expect(log.message).toBe(message);
});
});
//# sourceMappingURL=base.test.js.map
{
"name": "@timberio/core",
"version": "0.31.0",
"version": "0.32.0",
"description": "Timber.io - logging core",

@@ -40,6 +40,6 @@ "keywords": [

"dependencies": {
"@timberio/tools": "^0.31.0",
"@timberio/types": "^0.31.0"
"@timberio/tools": "^0.32.0",
"@timberio/types": "^0.32.0"
},
"gitHead": "03cb2806851c894e300389565ceae08df857461a"
"gitHead": "40b5f1cf02fb2552da392a3e04cb06a66453a21e"
}

@@ -56,7 +56,7 @@ # 🌲 Timber - logging core

timber.log("Once more, with context", {
custom: {
httpRequest: {
"user-agent": {
browser: "Chrome"
}
}
browser: "Chrome",
},
},
});

@@ -96,3 +96,3 @@ ```

// In this example function, we'll add a custom `context` to the log
// In this example function, we'll add custom 'context' meta to the log
// representing the currently logged in user.

@@ -105,9 +105,7 @@ //

...log, // <-- copy the existing log
context: {
user: {
// ... and add our own `context` data
user: {
id: 1000,
name: "Lee"
}
}
id: 1000,
name: "Lee",
},
};

@@ -114,0 +112,0 @@ }

@@ -104,3 +104,3 @@ import Base from "./base";

...log,
message: newMessage
message: newMessage,
};

@@ -226,4 +226,37 @@ });

// Context should contain a stack trace
expect((log.context as any).stack).toBe(e.stack);
expect((log as any).stack).toBe(e.stack);
});
it("should not ignore exceptions by default", async () => {
// Fixtures
const message = "Testing exceptions";
const e = new Error("Should NOT be ignored!");
const base = new Base("testing");
// Add a mock sync method which throws an error
base.setSync(async () => {
throw e;
});
expect(base.info(message)).rejects.toEqual(e);
});
it("should ignore exceptions if `ignoreExceptions` opt == true", async () => {
// Fixtures
const message = "Testing exceptions";
const base = new Base("testing", {
ignoreExceptions: true,
});
// Add a mock sync method which throws an error
base.setSync(async () => {
throw new Error("Should be ignored!");
});
// Log - shouldn't throw!
const log = await base.info(message);
// Should return the log, even though there was an error
expect(log.message).toBe(message);
});
});

@@ -7,3 +7,3 @@ import {

Middleware,
Sync
Sync,
} from "@timberio/types";

@@ -27,3 +27,6 @@ import { makeBatch, makeThrottle } from "@timberio/tools";

// Maximum number of sync requests to make concurrently
syncMax: 5
syncMax: 5,
// If true, errors/failed logs should be ignored
ignoreExceptions: false,
};

@@ -87,3 +90,3 @@

this._options.batchSize,
this._options.batchInterval
this._options.batchInterval,
);

@@ -99,3 +102,3 @@

return {
stack: e.stack
stack: e.stack,
};

@@ -135,3 +138,3 @@ }

level: LogLevel = LogLevel.Info,
context: TContext = {} as TContext
context: TContext = {} as TContext,
): Promise<ITimberLog & TContext> {

@@ -155,3 +158,3 @@ // Check that we have a sync function

// Add initial context
...context
...context,
};

@@ -171,3 +174,3 @@

// Add error message
message: message.message
message: message.message,
};

@@ -180,3 +183,3 @@ } else {

// Add string message
message
message,
};

@@ -188,10 +191,17 @@ }

(fn, pipedLog) => fn.then(pipedLog),
Promise.resolve(log as ITimberLog)
Promise.resolve(log as ITimberLog),
);
// Push the log through the batcher, and sync
await this._batch(transformedLog);
try {
// Push the log through the batcher, and sync
await this._batch(transformedLog);
// Increment sync count
this._countSynced++;
// Increment sync count
this._countSynced++;
} catch (e) {
// Catch any errors - re-throw if `ignoreExceptions` == false
if (!this._options.ignoreExceptions) {
throw e;
}
}

@@ -212,3 +222,3 @@ // Return the resulting log

message: Message,
context: TContext = {} as TContext
context: TContext = {} as TContext,
) {

@@ -228,3 +238,3 @@ return this.log(message, LogLevel.Debug, context);

message: Message,
context: TContext = {} as TContext
context: TContext = {} as TContext,
) {

@@ -244,3 +254,3 @@ return this.log(message, LogLevel.Info, context);

message: Message,
context: TContext = {} as TContext
context: TContext = {} as TContext,
) {

@@ -260,3 +270,3 @@ return this.log(message, LogLevel.Warn, context);

message: Message,
context: TContext = {} as TContext
context: TContext = {} as TContext,
) {

@@ -263,0 +273,0 @@ return this.log(message, LogLevel.Error, context);

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc