Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@openfn/logger

Package Overview
Dependencies
Maintainers
4
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@openfn/logger - npm Package Compare versions

Comparing version 0.0.12 to 0.0.13

20

dist/index.d.ts
declare type LogLevel = 'debug' | 'info' | 'default' | 'none';
declare type LogEmitter = typeof console & {
success: typeof console.log;
always: typeof console.log;
};

@@ -18,3 +19,3 @@ declare type LogOptions = {

declare type LogFns = 'debug' | 'info' | 'log' | 'warn' | 'error' | 'success';
declare type LogFns = 'debug' | 'info' | 'log' | 'warn' | 'error' | 'success' | 'always';
declare type JSONLog = {

@@ -36,2 +37,3 @@ message: Array<string | object | any>;

success(...args: any[]): void;
always(...args: any[]): void;
print(...args: any[]): void;

@@ -44,2 +46,9 @@ confirm(message: string, force?: boolean): Promise<boolean>;

declare type ParsedLog = {
level: string;
namespace?: string;
icon?: string;
message: string | object;
messageRaw: any[];
};
declare type MockLogger<T> = Logger & {

@@ -49,9 +58,4 @@ _last: T;

_reset: () => void;
_parse: (m: StringLog) => {
level: string;
namespace?: string;
icon?: string;
message: string | object;
messageRaw: any[];
};
_parse: (m: StringLog) => ParsedLog;
_find: (level: string, pattern: RegExp) => ParsedLog | undefined;
};

@@ -58,0 +62,0 @@ declare const mockLogger: <T = [LogFns | "confirm" | "print", ...any[]]>(name?: string, opts?: LogOptions) => MockLogger<T>;

46

dist/index.js

@@ -13,2 +13,3 @@ // src/logger.ts

var cross = figures.cross;
var lozenge = "\u2666";

@@ -21,3 +22,3 @@ // src/sanitize.ts

if (item instanceof Error) {
return item.toString();
return item;
}

@@ -59,3 +60,4 @@ if (Array.isArray(item) || isNaN(item) && item && typeof item !== "string") {

...console,
success: (...args) => console.log(...args)
success: (...args) => console.log(...args),
always: (...args) => console.log(...args)
};

@@ -86,2 +88,3 @@ var defaults = {

var SUCCESS = "success";
var ALWAYS = "always";
var INFO = "info";

@@ -96,2 +99,3 @@ var DEBUG = "debug";

default: 2,
[ALWAYS]: 2,
[WARN]: 2,

@@ -110,2 +114,4 @@ [ERROR]: 2,

return c.green(tick);
case ALWAYS:
return c.white(lozenge);
case DEBUG:

@@ -137,2 +143,3 @@ return c.grey(pointer);

};
stringify2(output);
emitter[level](stringify2(output));

@@ -186,2 +193,3 @@ };

success: wrap(SUCCESS),
always: wrap(ALWAYS),
confirm,

@@ -210,12 +218,14 @@ timer,

};
["log", "info", "success", "debug", "warn", "error"].forEach((l) => {
const level = l;
logger[level] = (...out) => {
if (opts.json) {
history.push(out[0]);
} else {
history.push([level, ...out]);
}
};
});
["log", "info", "success", "always", "debug", "warn", "error"].forEach(
(l) => {
const level = l;
logger[level] = (...out) => {
if (opts.json) {
history.push(out[0]);
} else {
history.push([level, ...out]);
}
};
}
);
const m = logger_default(name, {

@@ -226,2 +236,4 @@ logger,

const mock = m;
mock.break = () => {
};
mock.print = (...out) => {

@@ -277,2 +289,12 @@ if (opts.level !== "none") {

};
mock._find = (level, re) => {
for (const item of history) {
if (Array.isArray(item) && item[0] === level) {
const parsed = mock._parse(item);
if (re.test(parsed.message)) {
return parsed;
}
}
}
};
mock.confirm = async (message) => {

@@ -279,0 +301,0 @@ history.push(["confirm", message]);

{
"name": "@openfn/logger",
"version": "0.0.12",
"version": "0.0.13",
"description": "Cross-package logging utility",

@@ -5,0 +5,0 @@ "module": "dist/index.js",

@@ -58,2 +58,3 @@ ## @openfn/logger

✔ success
♦ always
⚠ warn

@@ -60,0 +61,0 @@ ✘ error

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