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

@bettercorp/service-base

Package Overview
Dependencies
Maintainers
2
Versions
443
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bettercorp/service-base - npm Package Compare versions

Comparing version 8.5.53 to 8.5.54

5

lib/base/errorMessages.d.ts
import { LogMeta } from "../interfaces";
export type EMetaDef<T extends string> = {
message: T;
meta: LogMeta<T>;
};
export declare class BSBError<T extends string> extends Error {
constructor(errorKey: string, message: T, meta: LogMeta<T>);
constructor(message: T, meta: LogMeta<T>);
raw: EMetaDef<string> | null;
toString(): string;
}
export declare function BSB_ERROR_METHOD_NOT_IMPLEMENTED(className: string, method: string): BSBError<"Method not implemented: {class}.{method}">;

@@ -11,2 +11,6 @@ "use strict";

this.name = "BSBError-Generic";
this.raw = {
message: errorKeyOrMessage,
meta: messageOrMeta,
};
}

@@ -16,4 +20,17 @@ else if (typeof messageOrMeta === "string" && typeof meta === "object") {

this.name = "BSBError-" + errorKeyOrMessage;
this.raw = {
message: messageOrMeta,
meta: meta,
};
}
else {
super(errorKeyOrMessage);
this.name = "BSBError-Generic";
this.raw = {
message: errorKeyOrMessage,
meta: messageOrMeta ?? {},
};
}
}
raw = null;
toString() {

@@ -20,0 +37,0 @@ return this.message;

4

lib/base/logging.d.ts

@@ -13,3 +13,3 @@ import { LogMeta } from "../interfaces";

abstract warn<T extends string>(plugin: string, message: T, meta?: LogMeta<T>): Promise<void> | void;
abstract error<T extends string>(plugin: string, message: T, meta?: LogMeta<T>): Promise<void> | void;
abstract error<T extends string>(plugin: string, messageOrError: T, errorOrMeta?: Error | LogMeta<T>, meta?: LogMeta<T>): Promise<void> | void;
}

@@ -22,5 +22,5 @@ export declare class BSBLoggingRef extends BSBLogging<null> {

warn<T extends string>(plugin: string, message: T, meta?: LogMeta<T> | undefined): void;
error<T extends string>(plugin: string, message: T, meta?: LogMeta<T> | undefined): void;
error<T extends string>(plugin: string, messageOrError: T, errorOrMeta?: Error | LogMeta<T>, meta?: LogMeta<T>): void;
dispose?(): void;
init?(): void;
}

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

}
error(plugin, message, meta) {
error(plugin, messageOrError, errorOrMeta, meta) {
throw (0, index_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBLoggingRef", "error");

@@ -31,0 +31,0 @@ }

import { SBLogging } from "../serviceBase";
import { DEBUG_MODE, SmartLogMeta, IPluginLogger } from "../interfaces";
import { BSBError } from "./errorMessages";
export declare class PluginLogger implements IPluginLogger {

@@ -13,3 +14,5 @@ private logging;

warn<T extends string>(message: T, ...meta: SmartLogMeta<T>): void;
error<T extends string>(message: T, ...meta: SmartLogMeta<T>): void;
error<T extends string>(error: BSBError<T>): void;
error<T extends string>(message: T, error: Error, meta: SmartLogMeta<T>): void;
error<T extends string>(message: T, meta: SmartLogMeta<T>): void;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PluginLogger = void 0;
const errorMessages_1 = require("./errorMessages");
class PluginLogger {

@@ -17,3 +18,3 @@ logging;

if (this.canDebug)
this.logging.logBus.emit("debug", this.pluginName, message, meta[0]);
this.logging.logBus.emit("debug", this.pluginName, message, ...meta);
}

@@ -24,12 +25,20 @@ reportStat(key, value) {

reportTextStat(message, ...meta) {
this.logging.logBus.emit("reportTextStat", this.pluginName, message, meta[0]);
this.logging.logBus.emit("reportTextStat", this.pluginName, message, meta);
}
info(message, ...meta) {
this.logging.logBus.emit("info", this.pluginName, message, meta[0]);
this.logging.logBus.emit("info", this.pluginName, message, meta);
}
warn(message, ...meta) {
this.logging.logBus.emit("warn", this.pluginName, message, meta[0]);
this.logging.logBus.emit("warn", this.pluginName, message, meta);
}
error(message, ...meta) {
this.logging.logBus.emit("error", this.pluginName, message, meta[0]);
error(messageOrError, errorOrMeta, meta) {
if (messageOrError instanceof errorMessages_1.BSBError) {
if (messageOrError.raw !== null) {
this.logging.logBus.emit("error", this.pluginName, messageOrError.raw.message, messageOrError, messageOrError.raw.meta);
return;
}
this.logging.logBus.emit("error", this.pluginName, messageOrError.message, messageOrError, {});
return;
}
this.logging.logBus.emit("error", this.pluginName, messageOrError, errorOrMeta, meta);
}

@@ -36,0 +45,0 @@ }

import { ParamsFromString } from "@bettercorp/tools/lib/Interfaces";
import { BSBError } from "../base";
export type DEBUG_MODE = "production" | "production-debug" | "development";

@@ -17,2 +18,4 @@ export type SafeLogData = string | number | boolean | Array<string | number | boolean> | Object;

error<T extends string>(message: T, ...meta: SmartLogMeta<T>): void;
error<T extends string>(message: T, error: Error, ...meta: SmartLogMeta<T>): void;
error<T extends string>(error: BSBError<T>): void;
}

@@ -19,0 +22,0 @@ export declare const LoggingEventTypesBase: {

@@ -26,4 +26,3 @@ import { LogMeta, BSBLogging, BSBLoggingConstructor } from "../../";

warn<T extends string>(plugin: string, message: T, meta: LogMeta<T>): void;
error<T extends string>(plugin: string, message: T, meta: LogMeta<T>): void;
error(plugin: string, error: Error): void;
error<T extends string>(plugin: string, message: T, errorOrMeta?: Error | LogMeta<T>, meta?: LogMeta<T>): void;
}

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

}
logEvent(level, plugin, message, meta) {
logEvent(level, plugin, message, meta, additionalToConsole) {
let formattedMessage = this.logFormatter.formatLog(message, meta);

@@ -62,2 +62,4 @@ formattedMessage = `[${plugin.toUpperCase()}] ${formattedMessage}`;

return this._mockedConsole(level, formattedMessage);
if (additionalToConsole)
func(colour.join("") + "%s" + colours_1.CONSOLE_COLOURS.Reset, formattedMessage, additionalToConsole);
func(colour.join("") + "%s" + colours_1.CONSOLE_COLOURS.Reset, formattedMessage);

@@ -86,11 +88,6 @@ }

}
error(plugin, messageOrError, meta) {
const message = typeof messageOrError === "string"
? messageOrError
: messageOrError.message;
this.logEvent(exports.LOG_LEVELS.ERROR, plugin, message, meta);
if (typeof messageOrError !== "string" &&
messageOrError.stack !== undefined) {
console.error(messageOrError.stack.toString());
}
error(plugin, message, errorOrMeta, meta) {
const hasErrorDefinition = meta !== undefined;
const inclStack = errorOrMeta instanceof Error && errorOrMeta.stack;
this.logEvent(exports.LOG_LEVELS.ERROR, plugin, message, hasErrorDefinition ? meta : errorOrMeta, inclStack ? errorOrMeta.stack : undefined);
}

@@ -97,0 +94,0 @@ }

@@ -51,4 +51,4 @@ "use strict";

});
this.logBus.on("error", (plugin, message, meta) => {
this.triggerLogEvent("error", plugin, message, meta);
this.logBus.on("error", (plugin, message, errorOrMeta, meta) => {
this.triggerLogEvent("error", plugin, message, errorOrMeta, meta);
});

@@ -94,6 +94,6 @@ }

}
async triggerLogEvent(logAs, plugin, messageOrKey, metaOrValue) {
async triggerLogEvent(logAs, plugin, messageOrKey, metaOrValueOrError, meta) {
for (const logger of this.getPluginsMatchingLogEvent(logAs, plugin)) {
if (logAs === "reportStat") {
await this.triggerLogEventReportStat(logger.plugin, plugin, messageOrKey, metaOrValue);
await this.triggerLogEventReportStat(logger.plugin, plugin, messageOrKey, metaOrValueOrError);
continue;

@@ -116,7 +116,7 @@ }

case "error":
method = logger.plugin.error;
return await (0, __1.SmartFunctionCallAsync)(logger.plugin, logger.plugin.error, plugin, messageOrKey, metaOrValueOrError, meta);
break;
}
if (method) {
await (0, __1.SmartFunctionCallAsync)(logger.plugin, method, plugin, messageOrKey, metaOrValue);
await (0, __1.SmartFunctionCallAsync)(logger.plugin, method, plugin, messageOrKey, metaOrValueOrError);
}

@@ -123,0 +123,0 @@ }

@@ -31,3 +31,3 @@ {

"main": "lib/index.js",
"version": "8.5.53",
"version": "8.5.54",
"bsb_project": true,

@@ -34,0 +34,0 @@ "bsbInit": {

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

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