diff --git a/History.md b/History.md new file mode 100644 index 0000000..1f49fe3 --- /dev/null +++ b/History.md @@ -0,0 +1,10 @@ +# Changelog for Anyhow + +1.1.0 +===== +* NEW! Added supoort for Pino. +* NEW! Propery "lib" defining the underlying library. + +1.0.0 +===== +* Initial release. diff --git a/docs/assets/js/search.js b/docs/assets/js/search.js index 584c032..dde0470 100644 --- a/docs/assets/js/search.js +++ b/docs/assets/js/search.js @@ -1,3 +1,3 @@ var typedoc = typedoc || {}; typedoc.search = typedoc.search || {}; - typedoc.search.data = {"kinds":{"1":"External module","32":"Variable","128":"Class","1024":"Property","2048":"Method","262144":"Accessor","2097152":"Object literal"},"rows":[{"id":0,"kind":1,"name":"\"index\"","url":"modules/_index_.html","classes":"tsd-kind-external-module"},{"id":1,"kind":128,"name":"Anyhow","url":"classes/_index_.anyhow.html","classes":"tsd-kind-class tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"index\""},{"id":2,"kind":262144,"name":"isReady","url":"classes/_index_.anyhow.html#isready","classes":"tsd-kind-get-signature tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":3,"kind":1024,"name":"compact","url":"classes/_index_.anyhow.html#compact","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":4,"kind":1024,"name":"errorStack","url":"classes/_index_.anyhow.html#errorstack","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":5,"kind":1024,"name":"levels","url":"classes/_index_.anyhow.html#levels","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":6,"kind":1024,"name":"separator","url":"classes/_index_.anyhow.html#separator","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":7,"kind":2097152,"name":"styles","url":"classes/_index_.anyhow.html#styles","classes":"tsd-kind-object-literal tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":8,"kind":32,"name":"debug","url":"classes/_index_.anyhow.html#styles.debug-1","classes":"tsd-kind-variable tsd-parent-kind-object-literal tsd-is-not-exported","parent":"\"index\".Anyhow.styles"},{"id":9,"kind":32,"name":"info","url":"classes/_index_.anyhow.html#styles.info-1","classes":"tsd-kind-variable tsd-parent-kind-object-literal tsd-is-not-exported","parent":"\"index\".Anyhow.styles"},{"id":10,"kind":32,"name":"warn","url":"classes/_index_.anyhow.html#styles.warn-1","classes":"tsd-kind-variable tsd-parent-kind-object-literal tsd-is-not-exported","parent":"\"index\".Anyhow.styles"},{"id":11,"kind":32,"name":"error","url":"classes/_index_.anyhow.html#styles.error-1","classes":"tsd-kind-variable tsd-parent-kind-object-literal tsd-is-not-exported","parent":"\"index\".Anyhow.styles"},{"id":12,"kind":1024,"name":"preprocessor","url":"classes/_index_.anyhow.html#preprocessor","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":13,"kind":2048,"name":"log","url":"classes/_index_.anyhow.html#log","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":14,"kind":2048,"name":"debug","url":"classes/_index_.anyhow.html#debug","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":15,"kind":2048,"name":"info","url":"classes/_index_.anyhow.html#info","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":16,"kind":2048,"name":"warn","url":"classes/_index_.anyhow.html#warn","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":17,"kind":2048,"name":"error","url":"classes/_index_.anyhow.html#error","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":18,"kind":2048,"name":"console","url":"classes/_index_.anyhow.html#console","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":19,"kind":2048,"name":"setup","url":"classes/_index_.anyhow.html#setup","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":20,"kind":2048,"name":"getMessage","url":"classes/_index_.anyhow.html#getmessage","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"}]}; \ No newline at end of file + typedoc.search.data = {"kinds":{"1":"External module","32":"Variable","128":"Class","1024":"Property","2048":"Method","262144":"Accessor","2097152":"Object literal"},"rows":[{"id":0,"kind":1,"name":"\"index\"","url":"modules/_index_.html","classes":"tsd-kind-external-module"},{"id":1,"kind":128,"name":"Anyhow","url":"classes/_index_.anyhow.html","classes":"tsd-kind-class tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"index\""},{"id":2,"kind":262144,"name":"isReady","url":"classes/_index_.anyhow.html#isready","classes":"tsd-kind-get-signature tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":3,"kind":262144,"name":"lib","url":"classes/_index_.anyhow.html#lib","classes":"tsd-kind-get-signature tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":4,"kind":1024,"name":"compact","url":"classes/_index_.anyhow.html#compact","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":5,"kind":1024,"name":"errorStack","url":"classes/_index_.anyhow.html#errorstack","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":6,"kind":1024,"name":"levels","url":"classes/_index_.anyhow.html#levels","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":7,"kind":1024,"name":"separator","url":"classes/_index_.anyhow.html#separator","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":8,"kind":2097152,"name":"styles","url":"classes/_index_.anyhow.html#styles","classes":"tsd-kind-object-literal tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":9,"kind":32,"name":"debug","url":"classes/_index_.anyhow.html#styles.debug-1","classes":"tsd-kind-variable tsd-parent-kind-object-literal tsd-is-not-exported","parent":"\"index\".Anyhow.styles"},{"id":10,"kind":32,"name":"info","url":"classes/_index_.anyhow.html#styles.info-1","classes":"tsd-kind-variable tsd-parent-kind-object-literal tsd-is-not-exported","parent":"\"index\".Anyhow.styles"},{"id":11,"kind":32,"name":"warn","url":"classes/_index_.anyhow.html#styles.warn-1","classes":"tsd-kind-variable tsd-parent-kind-object-literal tsd-is-not-exported","parent":"\"index\".Anyhow.styles"},{"id":12,"kind":32,"name":"error","url":"classes/_index_.anyhow.html#styles.error-1","classes":"tsd-kind-variable tsd-parent-kind-object-literal tsd-is-not-exported","parent":"\"index\".Anyhow.styles"},{"id":13,"kind":1024,"name":"preprocessor","url":"classes/_index_.anyhow.html#preprocessor","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":14,"kind":2048,"name":"log","url":"classes/_index_.anyhow.html#log","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":15,"kind":2048,"name":"debug","url":"classes/_index_.anyhow.html#debug","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":16,"kind":2048,"name":"info","url":"classes/_index_.anyhow.html#info","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":17,"kind":2048,"name":"warn","url":"classes/_index_.anyhow.html#warn","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":18,"kind":2048,"name":"error","url":"classes/_index_.anyhow.html#error","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":19,"kind":2048,"name":"console","url":"classes/_index_.anyhow.html#console","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":20,"kind":2048,"name":"setup","url":"classes/_index_.anyhow.html#setup","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"},{"id":21,"kind":2048,"name":"getMessage","url":"classes/_index_.anyhow.html#getmessage","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"index\".Anyhow"}]}; \ No newline at end of file diff --git a/docs/classes/_index_.anyhow.html b/docs/classes/_index_.anyhow.html index 34738c7..872b0b4 100644 --- a/docs/classes/_index_.anyhow.html +++ b/docs/classes/_index_.anyhow.html @@ -105,6 +105,7 @@

Properties

Accessors

@@ -137,7 +138,7 @@

compact

compact: boolean = true
@@ -153,7 +154,7 @@

errorStack

errorStack: boolean = false
@@ -169,7 +170,7 @@

levels

levels: string[] = ["info", "warn", "error"]
@@ -185,7 +186,7 @@

preprocessor

preprocessor: Function
@@ -203,7 +204,7 @@

separator

separator: string = " | "
@@ -226,7 +227,7 @@

isReady

  • @@ -238,6 +239,28 @@

    Returns boolean

  • +
    + +

    lib

    + + +

    Methods

    @@ -251,7 +274,7 @@

    console

  • @@ -290,7 +313,7 @@

    debug

  • @@ -318,7 +341,7 @@

    error

  • @@ -346,7 +369,7 @@

    getMessage

  • @@ -378,7 +401,7 @@

    info

  • @@ -406,7 +429,7 @@

    log

  • @@ -444,7 +467,7 @@

    setup

  • @@ -484,7 +507,7 @@

    warn

  • @@ -511,7 +534,7 @@

    styles

    styles: object
    @@ -526,7 +549,7 @@

    debug

    debug: string[] = ["gray"]
    @@ -541,7 +564,7 @@

    error

    error: string[] = ["red", "bold"]
    @@ -556,7 +579,7 @@

    info

    info: string[] = ["white"]
    @@ -571,7 +594,7 @@

    warn

    warn: string[] = ["yellow"]
    @@ -619,6 +642,9 @@

    warn

  • isReady
  • +
  • + lib +
  • console
  • diff --git a/lib/index.d.ts b/lib/index.d.ts index 9786779..0a5093e 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -14,6 +14,15 @@ declare class Anyhow { * Private logging function. This will be set on [[setup]]. */ private _log; + /** + * Name of the current library being used, populated on setup(). + * Possible values are console, winston, bunyan and pino. + */ + private _lib; + /** + * Getter for _lib, to be used by external modules. + */ + readonly lib: string; /** * Messages will be compacted (spaces and breaks removed), default is true. * Set to false to log original values including spaces. diff --git a/lib/index.js b/lib/index.js index 228d4c3..533aecc 100644 --- a/lib/index.js +++ b/lib/index.js @@ -10,6 +10,11 @@ let chalk = null; */ class Anyhow { constructor() { + /** + * Name of the current library being used, populated on setup(). + * Possible values are console, winston, bunyan and pino. + */ + this._lib = null; /** * Messages will be compacted (spaces and breaks removed), default is true. * Set to false to log original values including spaces. @@ -60,6 +65,12 @@ class Anyhow { } return false; } + /** + * Getter for _lib, to be used by external modules. + */ + get lib() { + return this._lib; + } // LOGGING METHODS // -------------------------------------------------------------------------- /** @@ -160,12 +171,13 @@ class Anyhow { */ setup(lib, options) { let found = false; - let winston, bunyan; + let winston, bunyan, pino; // Set defaults. lib = lib || "console"; options = options || {}; // Passed "none"? This will effectively disable logging. if (lib == "none") { + this._lib = null; this._log = function () { return false; }; @@ -181,8 +193,12 @@ class Anyhow { bunyan = lib; lib = "bunyan"; } + else if (lib.constructor.name == "Pino" && lib.levels) { + bunyan = lib; + lib = "pino"; + } else { - console.warn("Anyhow.setup", "Passed object was not recognized as Winston or Bunyan."); + console.warn("Anyhow.setup", "Passed object was not recognized as Winston / Bunyan / Pino."); } } // First try Winston. It will check if a Winston logger was passed directly @@ -192,6 +208,7 @@ class Anyhow { if (!winston) { winston = require("winston"); } + this._lib = "winston"; this._log = function (level, message) { winston.log({ level: level, message: message }); }; @@ -212,6 +229,7 @@ class Anyhow { if (!bunyan) { bunyan = require("bunyan").createLogger(options); } + this._lib = "bunyan"; this._log = function (level, message) { bunyan[level](message); }; @@ -222,6 +240,27 @@ class Anyhow { console.error("Anyhow.setup", "Could not load bunyan", ex); } } + // Then Pino. It will check if a Pino logger was passed directly + // as `lib`, or create a default logger if passed as string. + if (lib == "pino") { + try { + if (!options.name) { + options.name = "Anyhow"; + } + if (!pino) { + pino = require("pino")(); + } + this._lib = "pino"; + this._log = function (level, message) { + pino[level](message); + }; + found = true; + } + catch (ex) { + /* istanbul ignore next */ + console.error("Anyhow.setup", "Could not load pino", ex); + } + } // No logging libraries found? Fall back to console. if (!found) { try { @@ -230,6 +269,7 @@ class Anyhow { } } catch (ex) { } + this._lib = "console"; this._log = (level, message) => this.console(level, message); } } diff --git a/package-lock.json b/package-lock.json index dddaa31..eaece27 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "anyhow", - "version": "1.0.0", + "version": "1.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -819,6 +819,12 @@ "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", "dev": true }, + "fast-redact": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-1.5.0.tgz", + "integrity": "sha512-Afo61CgUjkzdvOKDHn08qnZ0kwck38AOGcMlvSGzvJbIab6soAP5rdoQayecGCDsD69AiF9vJBXyq31eoEO2tQ==", + "dev": true + }, "fast-safe-stringify": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.6.tgz", @@ -860,6 +866,12 @@ "is-buffer": "~2.0.3" } }, + "flatstr": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/flatstr/-/flatstr-1.0.12.tgz", + "integrity": "sha512-4zPxDyhCyiN2wIAtSLI6gc82/EjqZc1onI4Mz/l0pWrAlsSfYH/2ZIcU+e3oA2wDwbzIWNKwa23F8rh6+DRWkw==", + "dev": true + }, "foreground-child": { "version": "1.5.6", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-1.5.6.tgz", @@ -2104,6 +2116,26 @@ "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", "dev": true }, + "pino": { + "version": "5.12.5", + "resolved": "https://registry.npmjs.org/pino/-/pino-5.12.5.tgz", + "integrity": "sha512-Y493vt9ci7Jez3WZ/aUArijTQZXbHgWvDB3TMZlTu731p2kan/qyJk5k46aveEmYFnTlEommc+PSncUcuiMrBg==", + "dev": true, + "requires": { + "fast-redact": "^1.4.4", + "fast-safe-stringify": "^2.0.6", + "flatstr": "^1.0.9", + "pino-std-serializers": "^2.3.0", + "quick-format-unescaped": "^3.0.2", + "sonic-boom": "^0.7.3" + } + }, + "pino-std-serializers": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-2.4.1.tgz", + "integrity": "sha512-v/JglhO0aFcvkMV9VUxhgyuJo8K1si857Ww86Tx8H2cjC/kp0ndzzcF6Vbxr4RgKFYJdHfLVpEuD55znMZuxnw==", + "dev": true + }, "pkg-dir": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", @@ -2159,6 +2191,12 @@ "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", "dev": true }, + "quick-format-unescaped": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-3.0.2.tgz", + "integrity": "sha512-FXTaCkwvpIlkdKeGDNgcq07SXWS383noQUuZjvdE1QcTt+eLuqof6/BDiEPqB59FWLie/l91+HtlJSw7iCViSA==", + "dev": true + }, "randomstring": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/randomstring/-/randomstring-1.1.5.tgz", @@ -2380,6 +2418,15 @@ } } }, + "sonic-boom": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-0.7.4.tgz", + "integrity": "sha512-8JRAJg0RxZtFLQMxolwETvWd2JSlH3ZGo/Z4xPxMbpqF14xCgVYPVeFCFOR3zyr3pcfG82QDVj6537Sx5ZWdNw==", + "dev": true, + "requires": { + "flatstr": "^1.0.9" + } + }, "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", diff --git a/package.json b/package.json index 46af561..762601d 100755 --- a/package.json +++ b/package.json @@ -1,13 +1,14 @@ { "name": "anyhow", - "version": "1.0.0", - "description": "Drop-in wrapper for Winston, Bunyan and console logs.", + "version": "1.1.0", + "description": "Drop-in wrapper for Winston, Bunyan, Pino and console logs.", "keywords": [ "anyhow", "bunyan", "console", "logger", "logging", + "pino", "winston" ], "author": "Igor Ramadas ", @@ -36,9 +37,10 @@ "chai": "^4.2.0", "chalk": "^2.4.2", "coveralls": "^3.0.3", - "nyc": "^14.1.1", "mocha": "^6.1.4", "mocha-lcov-reporter": "^1.3.0", + "nyc": "^14.1.1", + "pino": "^5.12.5", "supertest": "^4.0.2", "typedoc": "^0.14.2", "typescript": "^3.4.5", diff --git a/src/index.ts b/src/index.ts index e457c3d..39af6bb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -35,6 +35,19 @@ class Anyhow { */ private _log: Function + /** + * Name of the current library being used, populated on setup(). + * Possible values are console, winston, bunyan and pino. + */ + private _lib: string = null + + /** + * Getter for _lib, to be used by external modules. + */ + get lib() { + return this._lib + } + /** * Messages will be compacted (spaces and breaks removed), default is true. * Set to false to log original values including spaces. @@ -190,7 +203,7 @@ class Anyhow { */ setup(lib?: string | any, options?: any): void { let found = false - let winston, bunyan + let winston, bunyan, pino // Set defaults. lib = lib || "console" @@ -198,6 +211,7 @@ class Anyhow { // Passed "none"? This will effectively disable logging. if (lib == "none") { + this._lib = null this._log = function() { return false } @@ -213,8 +227,11 @@ class Anyhow { } else if (lib.constructor.name == "Logger" && lib.fields) { bunyan = lib lib = "bunyan" + } else if (lib.constructor.name == "Pino" && lib.levels) { + bunyan = lib + lib = "pino" } else { - console.warn("Anyhow.setup", "Passed object was not recognized as Winston or Bunyan.") + console.warn("Anyhow.setup", "Passed object was not recognized as Winston / Bunyan / Pino.") } } @@ -226,6 +243,7 @@ class Anyhow { winston = require("winston") } + this._lib = "winston" this._log = function(level, message) { winston.log({level: level, message: message}) } @@ -249,6 +267,7 @@ class Anyhow { bunyan = require("bunyan").createLogger(options) } + this._lib = "bunyan" this._log = function(level, message) { bunyan[level](message) } @@ -260,6 +279,30 @@ class Anyhow { } } + // Then Pino. It will check if a Pino logger was passed directly + // as `lib`, or create a default logger if passed as string. + if (lib == "pino") { + try { + if (!options.name) { + options.name = "Anyhow" + } + + if (!pino) { + pino = require("pino")() + } + + this._lib = "pino" + this._log = function(level, message) { + pino[level](message) + } + + found = true + } catch (ex) { + /* istanbul ignore next */ + console.error("Anyhow.setup", "Could not load pino", ex) + } + } + // No logging libraries found? Fall back to console. if (!found) { try { @@ -268,6 +311,7 @@ class Anyhow { } } catch (ex) {} + this._lib = "console" this._log = (level, message) => this.console(level, message) } } diff --git a/test/test-a.js b/test/test-a.js index 84f5e66..6644407 100644 --- a/test/test-a.js +++ b/test/test-a.js @@ -162,6 +162,8 @@ describe("Anyhow Tests", function() { if (logged.indexOf("should") > 0) { done(`Nothing should be logged, but got: ${logged}`) + } else if (anyhow.lib != null) { + done(`The .lib property should be null, but got: ${anyhow.lib}`) } else { done() } diff --git a/test/test-pino.js b/test/test-pino.js new file mode 100644 index 0000000..fc5de8c --- /dev/null +++ b/test/test-pino.js @@ -0,0 +1,57 @@ +// TEST: PINO + +let chai = require("chai") +let mocha = require("mocha") +let before = mocha.before +let describe = mocha.describe +let it = mocha.it + +chai.should() + +describe("Anyhow Pino Tests", function() { + let anyhow = null + let stdout = "" + + before(function() { + anyhow = require("../index") + + process.stdout.write = (function(write) { + return function(string) { + stdout += string; + write.apply(process.stdout, arguments); + } + })(process.stdout.write) + }) + + it("Log using default auto-created Pino console", function(done) { + anyhow.setup("pino", {}) + anyhow.info("Log to Pino") + + if (stdout.indexOf("Log to Pino") > 0) { + done() + } else { + done("Expected 'Log to Pino' on console output.") + } + }) + + it("Pass custom options to Pino", function() { + anyhow.setup("pino", { + name: "MyApp" + }) + }) + + it("Log passing Pino logger directly", function(done) { + let logger = require("pino")() + + anyhow.setup(logger) + anyhow.info("Log to custom Pino") + + if (stdout.indexOf("Log to custom Pino") < 0) { + done("Expected 'Log to custom Pino' on console output.") + } else if (anyhow.lib != "pino") { + done(`The .lib property should be 'pino', but got: ${anyhow.lib}`) + } else { + done() + } + }) +})