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.4 to 0.0.5

8

dist/index.d.ts

@@ -27,2 +27,4 @@ declare type LogLevel = 'debug' | 'info' | 'default' | 'none';

success(...args: any[]): void;
confirm(message: string, force?: boolean): Promise<boolean>;
timer(name: string): string | undefined;
break(): void;

@@ -32,3 +34,3 @@ }

declare type LogMessage = [LogFns, ...any[]];
declare type LogMessage = [LogFns | 'confirm', ...any[]];
declare type MockLogger = Logger & {

@@ -51,2 +53,4 @@ _last: LogMessage;

export { LogLevel, LogOptions, Logger, mockLogger as createMockLogger, export_default as default, _default$1 as isValidLogLevel, _default as printDuration };
declare const defaultLogger: Logger;
export { LogLevel, LogOptions, Logger, mockLogger as createMockLogger, export_default as default, defaultLogger, _default$1 as isValidLogLevel, _default as printDuration };
// src/logger.ts
import c from "chalk";
import Confirm from "prompt-confirm";

@@ -33,2 +34,15 @@ // src/symbols.ts

// src/util/duration.ts
var duration_default = (timeInMs) => {
if (timeInMs < 1e3) {
return `${timeInMs}ms`;
}
const seconds = timeInMs / 1e3;
if (seconds < 60) {
return `${seconds}s`;
}
const minutes = seconds / 60;
return `${Math.floor(minutes)}m ${seconds % 60}s`;
};
// src/options.ts

@@ -112,2 +126,18 @@ var defaultEmitter = {

};
const confirm = async (message, force = false) => {
if (force) {
return true;
}
const prompt = new Confirm({ message });
return prompt.run();
};
const timers = {};
const timer = (name2) => {
if (timers[name2]) {
const startTime = timers[name2];
delete timers[name2];
return duration_default(new Date().getTime() - startTime);
}
timers[name2] = new Date().getTime();
};
const wrap = (level) => (...args) => log(level, ...args);

@@ -121,2 +151,4 @@ const logger = {

success: wrap(SUCCESS),
confirm,
timer,
force: () => {

@@ -165,2 +197,5 @@ },

let messageParts = [];
if (log[0] === "confirm") {
return { level: "confirm", message: log[1] };
}
if (name && !opts.hideNamespace && !opts.hideIcons) {

@@ -188,2 +223,7 @@ [level, namespace, icon, ...messageParts] = log;

};
mock.confirm = async (message) => {
console.log(message);
history.push(["confirm", message]);
return true;
};
return mock;

@@ -196,16 +236,4 @@ };

// src/util/duration.ts
var duration_default = (timeInMs) => {
if (timeInMs < 1e3) {
return `${timeInMs}ms`;
}
const seconds = timeInMs / 1e3;
if (seconds < 60) {
return `${seconds}s`;
}
const minutes = seconds / 60;
return `${Math.floor(minutes)}m ${seconds % 60}s`;
};
// src/index.ts
var defaultLogger = logger_default();
var src_default = logger_default;

@@ -215,4 +243,5 @@ export {

src_default as default,
defaultLogger,
is_valid_log_level_default as isValidLogLevel,
duration_default as printDuration
};
{
"name": "@openfn/logger",
"version": "0.0.4",
"version": "0.0.5",
"description": "Cross-package logging utility",

@@ -23,3 +23,4 @@ "module": "dist/index.js",

"chalk": "4",
"figures": "^5.0.0"
"figures": "^5.0.0",
"prompt-confirm": "^2.0.4"
},

@@ -26,0 +27,0 @@ "devDependencies": {

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