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.19 to 0.0.20

7

CHANGELOG.md
# @openfn/logger
## 0.0.20
### Patch Changes
- 649ca43: In JSON mode, do not stringify emitted messages.
Better handling of error objects
## 0.0.19

@@ -4,0 +11,0 @@

56

dist/index.js
// src/logger.ts
import c from "chalk";
import iconfirm from "@inquirer/confirm";
import stringify2 from "fast-safe-stringify";

@@ -54,5 +53,25 @@ // src/symbols.ts

};
var isError = (obj) => {
if (obj instanceof Error) {
return true;
}
let o = obj;
while (o && o.constructor) {
if (o.constructor.name === "Error") {
return true;
}
o = o.prototype?.constructor;
}
return false;
};
var sanitize = (item, options = {}) => {
const maybeStringify = (o) => options.stringify === false ? o : stringify(o, void 0, 2);
if (item instanceof Error) {
if (isError(item)) {
if (options.serializeErrors) {
return {
name: item.name,
message: item.message || item.toString()
// TODO stack? Tricky
};
}
return item;

@@ -119,4 +138,4 @@ }

// src/options.ts
var defaultEmitter = {
// src/util/default-emitter.ts
var default_emitter_default = {
...console,

@@ -129,9 +148,22 @@ // Direct error and warn logs to stdout, so that they appear in sequence

};
// src/util/json-emitter.ts
import stringify2 from "fast-safe-stringify";
var jsonEmitter = {
...console
};
["log", "info", "success", "always", "debug", "warn", "error"].forEach((fn) => {
jsonEmitter[fn] = (...args) => {
const stringified = args.map((value) => stringify2(value));
console.log(...stringified);
};
});
var json_emitter_default = jsonEmitter;
// src/options.ts
var defaults = {
level: "default",
// TODO support an array of emitters here
logger: defaultEmitter,
// I guess?
hideNamespace: false,
hideIcons: false,
logger: default_emitter_default,
// Not implemented

@@ -149,2 +181,5 @@ wrap: false,

...defaults,
// If logging to json, and no emitter is provided,
// use this emitter which will serialise the output to JSON
logger: opts.json ? json_emitter_default : default_emitter_default,
...opts

@@ -209,3 +244,4 @@ };

stringify: false,
policy: options.sanitize
policy: options.sanitize,
serializeErrors: true
})

@@ -222,3 +258,3 @@ );

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

@@ -263,3 +299,3 @@ const logString = (name2, level, ...args) => {

if (opts.json) {
emitter.info(JSON.stringify({ message: args }));
emitter.info({ message: args });
} else {

@@ -266,0 +302,0 @@ emitter.info(...args);

2

package.json
{
"name": "@openfn/logger",
"version": "0.0.19",
"version": "0.0.20",
"description": "Cross-package logging utility",

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

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