Huge News!Announcing our $40M Series B led by Abstract Ventures.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.30.0 to 0.31.0

14

dist/cjs/base.d.ts

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

import { ITimberLog, ITimberOptions, LogLevel, Middleware, Sync } from "@timberio/types";
import { ITimberLog, ITimberOptions, Context, LogLevel, Middleware, Sync } from "@timberio/types";
declare type Message = string | Error;

@@ -39,6 +39,6 @@ /**

* @param level (LogLevel) - Level to log at (debug|info|warn|error)
* @param context: (Pick<ITimberLog, "context">) - Context (optional)
* @param context: (Context) - Context (optional)
* @returns Promise<ITimberLog> after syncing
*/
log(message: Message, level?: LogLevel, context?: Pick<ITimberLog, "context">): Promise<ITimberLog>;
log<TContext extends Context>(message: Message, level?: LogLevel, context?: TContext): Promise<ITimberLog & TContext>;
/**

@@ -52,3 +52,3 @@ *

*/
debug(message: Message, context?: Pick<ITimberLog, "context">): Promise<ITimberLog>;
debug<TContext extends Context>(message: Message, context?: TContext): Promise<ITimberLog & TContext>;
/**

@@ -62,3 +62,3 @@ *

*/
info(message: Message, context?: Pick<ITimberLog, "context">): Promise<ITimberLog>;
info<TContext extends Context>(message: Message, context?: TContext): Promise<ITimberLog & TContext>;
/**

@@ -72,3 +72,3 @@ *

*/
warn(message: Message, context?: Pick<ITimberLog, "context">): Promise<ITimberLog>;
warn<TContext extends Context>(message: Message, context?: TContext): Promise<ITimberLog & TContext>;
/**

@@ -82,3 +82,3 @@ *

*/
error(message: Message, context?: Pick<ITimberLog, "context">): Promise<ITimberLog>;
error<TContext extends Context>(message: Message, context?: TContext): Promise<ITimberLog & TContext>;
/**

@@ -85,0 +85,0 @@ * Sets the sync method - i.e. the final step in the pipeline to get logs

@@ -82,3 +82,3 @@ "use strict";

* @param level (LogLevel) - Level to log at (debug|info|warn|error)
* @param context: (Pick<ITimberLog, "context">) - Context (optional)
* @param context: (Context) - Context (optional)
* @returns Promise<ITimberLog> after syncing

@@ -94,16 +94,11 @@ */

// Start building the log message
let log = {
let log = Object.assign({
// Implicit date timestamp
dt: new Date(),
dt: new Date(),
// Explicit level
level,
// Add initial context
context
};
level }, context);
// Determine the type of message...
// Is this an error?
if (message instanceof Error) {
log = Object.assign({}, log, {
// Add stack trace
context: Object.assign({}, log.context, this.getContextFromError(message)),
log = Object.assign({}, log, this.getContextFromError(message), {
// Add error message

@@ -134,3 +129,3 @@ message: message.message });

*/
async debug(message, context) {
async debug(message, context = {}) {
return this.log(message, types_1.LogLevel.Debug, context);

@@ -146,3 +141,3 @@ }

*/
async info(message, context) {
async info(message, context = {}) {
return this.log(message, types_1.LogLevel.Info, context);

@@ -158,3 +153,3 @@ }

*/
async warn(message, context) {
async warn(message, context = {}) {
return this.log(message, types_1.LogLevel.Warn, context);

@@ -170,3 +165,3 @@ }

*/
async error(message, context) {
async error(message, context = {}) {
return this.log(message, types_1.LogLevel.Error, context);

@@ -173,0 +168,0 @@ }

@@ -6,2 +6,2 @@ import Base from "./base";

*/
Base, };
Base };

@@ -10,5 +10,5 @@ "use strict";

async function preProcess(log) {
return Object.assign({ date: new Date() }, log);
return Object.assign({ date: new Date() }, log);
}
exports.preProcess = preProcess;
//# sourceMappingURL=pipeline.js.map
//# sourceMappingURL=pipeline.js.map

@@ -5,16 +5,16 @@ "use strict";

describe("pipeline tests", () => {
test("preProcess should add missing date", async () => {
// Sample log, minus the date
const log = {
message: "Test"
};
// Run the log through the `preProcess` pipeline, which should add
// the missing date
const result = await pipeline_1.preProcess(log);
// Expect the message to be same
expect(result.message).toEqual(log.message);
// ... but a new `date` should be added
expect(result.date).not.toBeUndefined();
});
test("preProcess should add missing date", async () => {
// Sample log, minus the date
const log = {
message: "Test"
};
// Run the log through the `preProcess` pipeline, which should add
// the missing date
const result = await pipeline_1.preProcess(log);
// Expect the message to be same
expect(result.message).toEqual(log.message);
// ... but a new `date` should be added
expect(result.date).not.toBeUndefined();
});
});
//# sourceMappingURL=pipeline.test.js.map
//# sourceMappingURL=pipeline.test.js.map

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

import { ITimberLog, ITimberOptions, LogLevel, Middleware, Sync } from "@timberio/types";
import { ITimberLog, ITimberOptions, Context, LogLevel, Middleware, Sync } from "@timberio/types";
declare type Message = string | Error;

@@ -39,6 +39,6 @@ /**

* @param level (LogLevel) - Level to log at (debug|info|warn|error)
* @param context: (Pick<ITimberLog, "context">) - Context (optional)
* @param context: (Context) - Context (optional)
* @returns Promise<ITimberLog> after syncing
*/
log(message: Message, level?: LogLevel, context?: Pick<ITimberLog, "context">): Promise<ITimberLog>;
log<TContext extends Context>(message: Message, level?: LogLevel, context?: TContext): Promise<ITimberLog & TContext>;
/**

@@ -52,3 +52,3 @@ *

*/
debug(message: Message, context?: Pick<ITimberLog, "context">): Promise<ITimberLog>;
debug<TContext extends Context>(message: Message, context?: TContext): Promise<ITimberLog & TContext>;
/**

@@ -62,3 +62,3 @@ *

*/
info(message: Message, context?: Pick<ITimberLog, "context">): Promise<ITimberLog>;
info<TContext extends Context>(message: Message, context?: TContext): Promise<ITimberLog & TContext>;
/**

@@ -72,3 +72,3 @@ *

*/
warn(message: Message, context?: Pick<ITimberLog, "context">): Promise<ITimberLog>;
warn<TContext extends Context>(message: Message, context?: TContext): Promise<ITimberLog & TContext>;
/**

@@ -82,3 +82,3 @@ *

*/
error(message: Message, context?: Pick<ITimberLog, "context">): Promise<ITimberLog>;
error<TContext extends Context>(message: Message, context?: TContext): Promise<ITimberLog & TContext>;
/**

@@ -85,0 +85,0 @@ * Sets the sync method - i.e. the final step in the pipeline to get logs

@@ -80,3 +80,3 @@ import { LogLevel } from "@timberio/types";

* @param level (LogLevel) - Level to log at (debug|info|warn|error)
* @param context: (Pick<ITimberLog, "context">) - Context (optional)
* @param context: (Context) - Context (optional)
* @returns Promise<ITimberLog> after syncing

@@ -92,16 +92,11 @@ */

// Start building the log message
let log = {
let log = Object.assign({
// Implicit date timestamp
dt: new Date(),
dt: new Date(),
// Explicit level
level,
// Add initial context
context
};
level }, context);
// Determine the type of message...
// Is this an error?
if (message instanceof Error) {
log = Object.assign({}, log, {
// Add stack trace
context: Object.assign({}, log.context, this.getContextFromError(message)),
log = Object.assign({}, log, this.getContextFromError(message), {
// Add error message

@@ -132,3 +127,3 @@ message: message.message });

*/
async debug(message, context) {
async debug(message, context = {}) {
return this.log(message, LogLevel.Debug, context);

@@ -144,3 +139,3 @@ }

*/
async info(message, context) {
async info(message, context = {}) {
return this.log(message, LogLevel.Info, context);

@@ -156,3 +151,3 @@ }

*/
async warn(message, context) {
async warn(message, context = {}) {
return this.log(message, LogLevel.Warn, context);

@@ -168,3 +163,3 @@ }

*/
async error(message, context) {
async error(message, context = {}) {
return this.log(message, LogLevel.Error, context);

@@ -171,0 +166,0 @@ }

@@ -6,2 +6,2 @@ import Base from "./base";

*/
Base, };
Base };

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

*/
Base, };
Base };
//# sourceMappingURL=index.js.map

@@ -8,4 +8,4 @@ /**

export async function preProcess(log) {
return Object.assign({ date: new Date() }, log);
return Object.assign({ date: new Date() }, log);
}
//# sourceMappingURL=pipeline.js.map
//# sourceMappingURL=pipeline.js.map
import { preProcess } from "./pipeline";
describe("pipeline tests", () => {
test("preProcess should add missing date", async () => {
// Sample log, minus the date
const log = {
message: "Test"
};
// Run the log through the `preProcess` pipeline, which should add
// the missing date
const result = await preProcess(log);
// Expect the message to be same
expect(result.message).toEqual(log.message);
// ... but a new `date` should be added
expect(result.date).not.toBeUndefined();
});
test("preProcess should add missing date", async () => {
// Sample log, minus the date
const log = {
message: "Test"
};
// Run the log through the `preProcess` pipeline, which should add
// the missing date
const result = await preProcess(log);
// Expect the message to be same
expect(result.message).toEqual(log.message);
// ... but a new `date` should be added
expect(result.date).not.toBeUndefined();
});
});
//# sourceMappingURL=pipeline.test.js.map
//# sourceMappingURL=pipeline.test.js.map
{
"name": "@timberio/core",
"version": "0.30.0",
"version": "0.31.0",
"description": "Timber.io - logging core",

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

"dependencies": {
"@timberio/tools": "^0.30.0",
"@timberio/types": "^0.30.0"
"@timberio/tools": "^0.31.0",
"@timberio/types": "^0.31.0"
},
"gitHead": "16941238360eae52d6106dc864e11678fbac0636"
"gitHead": "03cb2806851c894e300389565ceae08df857461a"
}

@@ -58,5 +58,5 @@ # 🌲 Timber - logging core

"user-agent": {
browser: "Chrome",
},
},
browser: "Chrome"
}
}
});

@@ -108,5 +108,5 @@ ```

id: 1000,
name: "Lee",
},
},
name: "Lee"
}
}
};

@@ -113,0 +113,0 @@ }

import {
ITimberLog,
ITimberOptions,
Context,
LogLevel,

@@ -124,10 +125,10 @@ Middleware,

* @param level (LogLevel) - Level to log at (debug|info|warn|error)
* @param context: (Pick<ITimberLog, "context">) - Context (optional)
* @param context: (Context) - Context (optional)
* @returns Promise<ITimberLog> after syncing
*/
public async log(
public async log<TContext extends Context>(
message: Message,
level: LogLevel = LogLevel.Info,
context: Pick<ITimberLog, "context"> = {}
): Promise<ITimberLog> {
context: TContext = {} as TContext
): Promise<ITimberLog & TContext> {
// Check that we have a sync function

@@ -150,3 +151,3 @@ if (typeof this._sync !== "function") {

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

@@ -163,6 +164,3 @@

// Add stack trace
context: {
...log.context,
...this.getContextFromError(message)
},
...this.getContextFromError(message),

@@ -195,3 +193,3 @@ // Add error message

// Return the resulting log
return transformedLog;
return transformedLog as ITimberLog & TContext;
}

@@ -207,6 +205,6 @@

*/
public async debug(
public async debug<TContext extends Context>(
message: Message,
context?: Pick<ITimberLog, "context">
): Promise<ITimberLog> {
context: TContext = {} as TContext
) {
return this.log(message, LogLevel.Debug, context);

@@ -223,6 +221,6 @@ }

*/
public async info(
public async info<TContext extends Context>(
message: Message,
context?: Pick<ITimberLog, "context">
): Promise<ITimberLog> {
context: TContext = {} as TContext
) {
return this.log(message, LogLevel.Info, context);

@@ -239,6 +237,6 @@ }

*/
public async warn(
public async warn<TContext extends Context>(
message: Message,
context?: Pick<ITimberLog, "context">
): Promise<ITimberLog> {
context: TContext = {} as TContext
) {
return this.log(message, LogLevel.Warn, context);

@@ -255,6 +253,6 @@ }

*/
public async error(
public async error<TContext extends Context>(
message: Message,
context?: Pick<ITimberLog, "context">
): Promise<ITimberLog> {
context: TContext = {} as TContext
) {
return this.log(message, LogLevel.Error, context);

@@ -261,0 +259,0 @@ }

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

*/
Base,
Base
};

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