nightingale-console 11.7.4 → 12.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "root": true,
3
- "extends": ["@pob/eslint-config/root-commonjs"],
3
+ "extends": ["@pob/eslint-config/root-module"],
4
4
  "ignorePatterns": ["*.d.ts", "/dist"]
5
5
  }
package/CHANGELOG.md CHANGED
@@ -3,6 +3,60 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [12.1.1](https://github.com/christophehurpeau/nightingale/compare/v12.1.0...v12.1.1) (2022-01-01)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * properly configure package type ([2e0cbf5](https://github.com/christophehurpeau/nightingale/commit/2e0cbf555bd3b9fa3c3851025452937f64408aa8))
12
+
13
+
14
+
15
+
16
+
17
+ # [12.1.0](https://github.com/christophehurpeau/nightingale/compare/v12.0.1...v12.1.0) (2021-12-15)
18
+
19
+ **Note:** Version bump only for package nightingale-console
20
+
21
+
22
+
23
+
24
+
25
+ ## [12.0.1](https://github.com/christophehurpeau/nightingale/compare/v12.0.0...v12.0.1) (2021-12-12)
26
+
27
+ **Note:** Version bump only for package nightingale-console
28
+
29
+
30
+
31
+
32
+
33
+ # [12.0.0](https://github.com/christophehurpeau/nightingale/compare/v11.9.0...v12.0.0) (2021-12-11)
34
+
35
+
36
+ ### Bug Fixes
37
+
38
+ * missed legacy pob-babel ([82a38fa](https://github.com/christophehurpeau/nightingale/commit/82a38fa9743cfac3347386800070fea44d533321))
39
+
40
+
41
+ ### Build System
42
+
43
+ * node 14 and remove dev builds ([432ecd1](https://github.com/christophehurpeau/nightingale/commit/432ecd1faafd0419f57dea00fce560e4cccc207f))
44
+
45
+
46
+ ### Features
47
+
48
+ * drop default exports ([8878e49](https://github.com/christophehurpeau/nightingale/commit/8878e492b94852fcb892fd6d12c02c15c31b38b9))
49
+
50
+
51
+ ### BREAKING CHANGES
52
+
53
+ * use named imports instead of default exports
54
+ * requires node 14
55
+
56
+
57
+
58
+
59
+
6
60
  ## [11.7.4](https://github.com/christophehurpeau/nightingale/compare/v11.7.3...v11.7.4) (2021-11-27)
7
61
 
8
62
  **Note:** Version bump only for package nightingale-console
package/README.md CHANGED
@@ -20,7 +20,7 @@ npm install --save nightingale nightingale-console
20
20
 
21
21
  ```js
22
22
  import { configure, levels } from 'nightingale';
23
- import ConsoleHandler from 'nightingale-console';
23
+ import { ConsoleHandler } from 'nightingale-console';
24
24
 
25
25
  configure([{ handlers: [new ConsoleHandler(Level.INFO)] }]);
26
26
  ```
@@ -29,7 +29,7 @@ configure([{ handlers: [new ConsoleHandler(Level.INFO)] }]);
29
29
 
30
30
  `DEBUG=* node .`
31
31
 
32
- ```
32
+ ```js
33
33
  DEBUG='*'; # debug everything
34
34
  DEBUG=app # debug for logger with key 'app'
35
35
  DEBUG=app:* # debug for logger with key 'app' and all its children
@@ -24,8 +24,9 @@ const createHandle = (formatter = defaultFormatter, output = consoleOutput__defa
24
24
 
25
25
  const findDebugLevel = nightingaleDebug.createFindDebugLevel(process.env.DEBUG);
26
26
  class ConsoleHandler {
27
+ minLevel = nightingaleLevels.Level.ALL;
28
+
27
29
  constructor(minLevel, options = {}) {
28
- this.minLevel = nightingaleLevels.Level.ALL;
29
30
  this.minLevel = minLevel;
30
31
 
31
32
  this.isHandling = (level, key) => level >= findDebugLevel(minLevel, key);
@@ -36,5 +37,4 @@ class ConsoleHandler {
36
37
  }
37
38
 
38
39
  exports.ConsoleHandler = ConsoleHandler;
39
- exports["default"] = ConsoleHandler;
40
- //# sourceMappingURL=index-node12.cjs.js.map
40
+ //# sourceMappingURL=index-node14.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-node14.cjs.js","sources":["../src/index.ts"],"sourcesContent":["import formatterANSI from 'nightingale-ansi-formatter';\nimport consoleOutput from 'nightingale-console-output';\nimport { createFindDebugLevel } from 'nightingale-debug';\nimport formatterJSON from 'nightingale-json-formatter';\nimport { Level } from 'nightingale-levels';\nimport type {\n IsHandling,\n Handle,\n LogRecord,\n Metadata,\n Handler,\n} from 'nightingale-types';\n\nconst defaultFormatter =\n __POB_TARGET__ === 'node' &&\n !process.stdout.isTTY &&\n process.env.NIGHTINGALE_CONSOLE_FORMATTER !== 'ansi'\n ? formatterJSON\n : formatterANSI;\n\nconst createHandle = (\n formatter = defaultFormatter,\n output = consoleOutput,\n): Handle => {\n return <T extends Metadata>(record: LogRecord<T>): void => {\n output(formatter(record), record);\n };\n};\nconst findDebugLevel = createFindDebugLevel(process.env.DEBUG);\n\ninterface ConsoleHandlerOptions {\n formatter?: <T extends Metadata>(record: LogRecord<T>) => string;\n output?: <T extends Metadata>(\n param: string | string[],\n record: LogRecord<T>,\n ) => void;\n // compat with nightingale-app-console, not used yet\n theme?: 'dark' | 'light';\n}\n\nexport class ConsoleHandler implements Handler {\n minLevel: Level = Level.ALL;\n\n isHandling: IsHandling;\n\n handle: Handle;\n\n constructor(minLevel: Level, options: ConsoleHandlerOptions = {}) {\n this.minLevel = minLevel;\n this.isHandling = (level: Level, key: string) =>\n level >= findDebugLevel(minLevel, key);\n this.handle = createHandle(options.formatter, options.output);\n }\n}\n"],"names":["defaultFormatter","process","stdout","isTTY","env","NIGHTINGALE_CONSOLE_FORMATTER","formatterJSON","formatterANSI","createHandle","formatter","output","consoleOutput","record","findDebugLevel","createFindDebugLevel","DEBUG","ConsoleHandler","minLevel","Level","ALL","constructor","options","isHandling","level","key","handle"],"mappings":";;;;;;;;;;;;;;;;AAaA,MAAMA,gBAAgB,GAEpB,CAACC,OAAO,CAACC,MAAR,CAAeC,KADhB,IAEAF,OAAO,CAACG,GAAR,CAAYC,6BAAZ,KAA8C,MAF9C,GAGIC,sBAHJ,GAIIC,sBALN;;AAOA,MAAMC,YAAY,GAAG,CACnBC,SAAS,GAAGT,gBADO,EAEnBU,MAAM,GAAGC,sBAFU,KAGR;AACX,SAA4BC,MAArB,IAAoD;AACzDF,IAAAA,MAAM,CAACD,SAAS,CAACG,MAAD,CAAV,EAAoBA,MAApB,CAAN;AACD,GAFD;AAGD,CAPD;;AAQA,MAAMC,cAAc,GAAGC,qCAAoB,CAACb,OAAO,CAACG,GAAR,CAAYW,KAAb,CAA3C;AAYO,MAAMC,cAAN,CAAwC;AAC7CC,EAAAA,QAAQ,GAAUC,uBAAK,CAACC,GAAhB;;AAMRC,EAAAA,WAAW,CAACH,QAAD,EAAkBI,OAA8B,GAAG,EAAnD,EAAuD;AAChE,SAAKJ,QAAL,GAAgBA,QAAhB;;AACA,SAAKK,UAAL,GAAkB,CAACC,KAAD,EAAeC,GAAf,KAChBD,KAAK,IAAIV,cAAc,CAACI,QAAD,EAAWO,GAAX,CADzB;;AAEA,SAAKC,MAAL,GAAcjB,YAAY,CAACa,OAAO,CAACZ,SAAT,EAAoBY,OAAO,CAACX,MAA5B,CAA1B;AACD;;AAZ4C;;;;"}
@@ -14,8 +14,9 @@ const createHandle = (formatter = defaultFormatter, output = consoleOutput) => {
14
14
 
15
15
  const findDebugLevel = createFindDebugLevel(process.env.DEBUG);
16
16
  class ConsoleHandler {
17
+ minLevel = Level.ALL;
18
+
17
19
  constructor(minLevel, options = {}) {
18
- this.minLevel = Level.ALL;
19
20
  this.minLevel = minLevel;
20
21
 
21
22
  this.isHandling = (level, key) => level >= findDebugLevel(minLevel, key);
@@ -25,5 +26,5 @@ class ConsoleHandler {
25
26
 
26
27
  }
27
28
 
28
- export { ConsoleHandler, ConsoleHandler as default };
29
- //# sourceMappingURL=index-node12.mjs.map
29
+ export { ConsoleHandler };
30
+ //# sourceMappingURL=index-node14.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-node14.mjs","sources":["../src/index.ts"],"sourcesContent":["import formatterANSI from 'nightingale-ansi-formatter';\nimport consoleOutput from 'nightingale-console-output';\nimport { createFindDebugLevel } from 'nightingale-debug';\nimport formatterJSON from 'nightingale-json-formatter';\nimport { Level } from 'nightingale-levels';\nimport type {\n IsHandling,\n Handle,\n LogRecord,\n Metadata,\n Handler,\n} from 'nightingale-types';\n\nconst defaultFormatter =\n __POB_TARGET__ === 'node' &&\n !process.stdout.isTTY &&\n process.env.NIGHTINGALE_CONSOLE_FORMATTER !== 'ansi'\n ? formatterJSON\n : formatterANSI;\n\nconst createHandle = (\n formatter = defaultFormatter,\n output = consoleOutput,\n): Handle => {\n return <T extends Metadata>(record: LogRecord<T>): void => {\n output(formatter(record), record);\n };\n};\nconst findDebugLevel = createFindDebugLevel(process.env.DEBUG);\n\ninterface ConsoleHandlerOptions {\n formatter?: <T extends Metadata>(record: LogRecord<T>) => string;\n output?: <T extends Metadata>(\n param: string | string[],\n record: LogRecord<T>,\n ) => void;\n // compat with nightingale-app-console, not used yet\n theme?: 'dark' | 'light';\n}\n\nexport class ConsoleHandler implements Handler {\n minLevel: Level = Level.ALL;\n\n isHandling: IsHandling;\n\n handle: Handle;\n\n constructor(minLevel: Level, options: ConsoleHandlerOptions = {}) {\n this.minLevel = minLevel;\n this.isHandling = (level: Level, key: string) =>\n level >= findDebugLevel(minLevel, key);\n this.handle = createHandle(options.formatter, options.output);\n }\n}\n"],"names":["defaultFormatter","process","stdout","isTTY","env","NIGHTINGALE_CONSOLE_FORMATTER","formatterJSON","formatterANSI","createHandle","formatter","output","consoleOutput","record","findDebugLevel","createFindDebugLevel","DEBUG","ConsoleHandler","minLevel","Level","ALL","constructor","options","isHandling","level","key","handle"],"mappings":";;;;;;AAaA,MAAMA,gBAAgB,GAEpB,CAACC,OAAO,CAACC,MAAR,CAAeC,KADhB,IAEAF,OAAO,CAACG,GAAR,CAAYC,6BAAZ,KAA8C,MAF9C,GAGIC,aAHJ,GAIIC,aALN;;AAOA,MAAMC,YAAY,GAAG,CACnBC,SAAS,GAAGT,gBADO,EAEnBU,MAAM,GAAGC,aAFU,KAGR;AACX,SAA4BC,MAArB,IAAoD;AACzDF,IAAAA,MAAM,CAACD,SAAS,CAACG,MAAD,CAAV,EAAoBA,MAApB,CAAN;AACD,GAFD;AAGD,CAPD;;AAQA,MAAMC,cAAc,GAAGC,oBAAoB,CAACb,OAAO,CAACG,GAAR,CAAYW,KAAb,CAA3C;AAYO,MAAMC,cAAN,CAAwC;AAC7CC,EAAAA,QAAQ,GAAUC,KAAK,CAACC,GAAhB;;AAMRC,EAAAA,WAAW,CAACH,QAAD,EAAkBI,OAA8B,GAAG,EAAnD,EAAuD;AAChE,SAAKJ,QAAL,GAAgBA,QAAhB;;AACA,SAAKK,UAAL,GAAkB,CAACC,KAAD,EAAeC,GAAf,KAChBD,KAAK,IAAIV,cAAc,CAACI,QAAD,EAAWO,GAAX,CADzB;;AAEA,SAAKC,MAAL,GAAcjB,YAAY,CAACa,OAAO,CAACZ,SAAT,EAAoBY,OAAO,CAACX,MAA5B,CAA1B;AACD;;AAZ4C;;;;"}
package/dist/index.d.ts CHANGED
@@ -11,6 +11,5 @@ export declare class ConsoleHandler implements Handler {
11
11
  handle: Handle;
12
12
  constructor(minLevel: Level, options?: ConsoleHandlerOptions);
13
13
  }
14
- /** @deprecated use named export instead */
15
- export default ConsoleHandler;
14
+ export {};
16
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,EACV,UAAU,EACV,MAAM,EACN,SAAS,EACT,QAAQ,EACR,OAAO,EACR,MAAM,mBAAmB,CAAC;AAmB3B,UAAU,qBAAqB;IAC7B,SAAS,CAAC,EAAE,CAAC,CAAC,SAAS,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC;IACjE,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS,QAAQ,EAC1B,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EACxB,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,KACjB,IAAI,CAAC;IAEV,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED,qBAAa,cAAe,YAAW,OAAO;IAC5C,QAAQ,EAAE,KAAK,CAAa;IAE5B,UAAU,EAAE,UAAU,CAAC;IAEvB,MAAM,EAAE,MAAM,CAAC;gBAEH,QAAQ,EAAE,KAAK,EAAE,OAAO,GAAE,qBAA0B;CAMjE;AAED,2CAA2C;AAC3C,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,EACV,UAAU,EACV,MAAM,EACN,SAAS,EACT,QAAQ,EACR,OAAO,EACR,MAAM,mBAAmB,CAAC;AAmB3B,UAAU,qBAAqB;IAC7B,SAAS,CAAC,EAAE,CAAC,CAAC,SAAS,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC;IACjE,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS,QAAQ,EAC1B,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EACxB,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,KACjB,IAAI,CAAC;IAEV,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED,qBAAa,cAAe,YAAW,OAAO;IAC5C,QAAQ,EAAE,KAAK,CAAa;IAE5B,UAAU,EAAE,UAAU,CAAC;IAEvB,MAAM,EAAE,MAAM,CAAC;gBAEH,QAAQ,EAAE,KAAK,EAAE,OAAO,GAAE,qBAA0B;CAMjE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nightingale-console",
3
- "version": "11.7.4",
3
+ "version": "12.1.1",
4
4
  "description": "Console handler for nightingale",
5
5
  "keywords": [
6
6
  "nightingale",
@@ -14,32 +14,27 @@
14
14
  "directory": "packages/nightingale-console"
15
15
  },
16
16
  "homepage": "https://github.com/christophehurpeau/nightingale",
17
- "type": "commonjs",
17
+ "type": "module",
18
18
  "engines": {
19
- "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
19
+ "node": "^14.13.1 || >=16.0.0"
20
20
  },
21
- "main": "./dist/index-node12.cjs.js",
21
+ "main": "./dist/index-node14.cjs.js",
22
22
  "types": "./dist/index.d.ts",
23
23
  "exports": {
24
24
  "./package.json": "./package.json",
25
25
  ".": {
26
26
  "node": {
27
- "development": {
28
- "import": "./dist/index-node12-dev.mjs",
29
- "require": "./dist/index-node12-dev.cjs.js"
30
- },
31
- "import": "./dist/index-node12.mjs",
32
- "require": "./dist/index-node12.cjs.js"
27
+ "import": "./dist/index-node14.mjs",
28
+ "require": "./dist/index-node14.cjs.js"
33
29
  }
34
30
  }
35
31
  },
36
- "module:node": "./dist/index-node12.mjs",
37
- "module:node-dev": "./dist/index-node12-dev.mjs",
32
+ "module:node": "./dist/index-node14.mjs",
38
33
  "sideEffects": false,
39
34
  "scripts": {
40
35
  "build": "pob-build && yarn run build:definitions",
41
36
  "build:definitions": "tsc -p tsconfig.build.json",
42
- "clean": "rm -Rf docs dist test/node6 coverage",
37
+ "clean": "rm -Rf dist",
43
38
  "lint": "yarn run lint:eslint",
44
39
  "lint:eslint": "cd ../.. && yarn run eslint --report-unused-disable-directives --resolve-plugins-relative-to . --quiet packages/nightingale-console",
45
40
  "watch": "pob-watch"
@@ -53,7 +48,7 @@
53
48
  "babelEnvs": [
54
49
  {
55
50
  "target": "node",
56
- "version": "12",
51
+ "version": "14",
57
52
  "formats": [
58
53
  "cjs",
59
54
  "es"
@@ -65,20 +60,18 @@
65
60
  ]
66
61
  },
67
62
  "dependencies": {
68
- "@types/node": ">=12.0.0",
69
- "nightingale-ansi-formatter": "^11.7.4",
70
- "nightingale-console-output": "^11.7.4",
71
- "nightingale-debug": "^11.7.4",
72
- "nightingale-json-formatter": "^11.7.4",
73
- "nightingale-levels": "^11.7.2",
74
- "nightingale-types": "^11.7.4"
63
+ "@types/node": ">=14.0.0",
64
+ "nightingale-ansi-formatter": "12.1.1",
65
+ "nightingale-console-output": "12.1.1",
66
+ "nightingale-debug": "12.1.1",
67
+ "nightingale-json-formatter": "12.1.1",
68
+ "nightingale-levels": "12.1.1",
69
+ "nightingale-types": "12.1.1"
75
70
  },
76
71
  "devDependencies": {
77
- "@babel/core": "7.16.0",
78
- "babel-preset-latest-node": "5.5.1",
79
- "pob-babel": "28.5.0",
80
- "rollup": "2.60.1",
81
- "typescript": "4.5.2"
72
+ "@babel/core": "7.16.7",
73
+ "pob-babel": "29.6.1",
74
+ "typescript": "4.5.4"
82
75
  },
83
- "gitHead": "70f6b4ba634ff778fc94bef7e2455e8b6a7db06a"
76
+ "gitHead": "719598e0a3d508801b18542a1054301200b62ed0"
84
77
  }
@@ -9,5 +9,22 @@
9
9
  "@pob/eslint-config-typescript",
10
10
  "@pob/eslint-config-typescript/node"
11
11
  ],
12
- "ignorePatterns": ["*.d.ts"]
12
+ "ignorePatterns": ["*.d.ts"],
13
+ "overrides": [
14
+ {
15
+ "files": ["**/*.test.ts", "__tests__/**/*.ts"],
16
+ "extends": ["@pob/eslint-config-typescript/test"],
17
+ "env": {
18
+ "jest": true
19
+ },
20
+ "rules": {
21
+ "import/no-extraneous-dependencies": [
22
+ "error",
23
+ {
24
+ "devDependencies": true
25
+ }
26
+ ]
27
+ }
28
+ }
29
+ ]
13
30
  }
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { POB_TARGET } from 'pob-babel';
2
1
  import formatterANSI from 'nightingale-ansi-formatter';
3
2
  import consoleOutput from 'nightingale-console-output';
4
3
  import { createFindDebugLevel } from 'nightingale-debug';
@@ -13,7 +12,7 @@ import type {
13
12
  } from 'nightingale-types';
14
13
 
15
14
  const defaultFormatter =
16
- POB_TARGET === 'node' &&
15
+ __POB_TARGET__ === 'node' &&
17
16
  !process.stdout.isTTY &&
18
17
  process.env.NIGHTINGALE_CONSOLE_FORMATTER !== 'ansi'
19
18
  ? formatterJSON
@@ -53,6 +52,3 @@ export class ConsoleHandler implements Handler {
53
52
  this.handle = createHandle(options.formatter, options.output);
54
53
  }
55
54
  }
56
-
57
- /** @deprecated use named export instead */
58
- export default ConsoleHandler;
@@ -1,40 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const formatterANSI = require('nightingale-ansi-formatter');
6
- const consoleOutput = require('nightingale-console-output');
7
- const nightingaleDebug = require('nightingale-debug');
8
- const formatterJSON = require('nightingale-json-formatter');
9
- const nightingaleLevels = require('nightingale-levels');
10
-
11
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
12
-
13
- const formatterANSI__default = /*#__PURE__*/_interopDefaultLegacy(formatterANSI);
14
- const consoleOutput__default = /*#__PURE__*/_interopDefaultLegacy(consoleOutput);
15
- const formatterJSON__default = /*#__PURE__*/_interopDefaultLegacy(formatterJSON);
16
-
17
- const defaultFormatter = !process.stdout.isTTY && process.env.NIGHTINGALE_CONSOLE_FORMATTER !== 'ansi' ? formatterJSON__default : formatterANSI__default;
18
-
19
- const createHandle = (formatter = defaultFormatter, output = consoleOutput__default) => {
20
- return record => {
21
- output(formatter(record), record);
22
- };
23
- };
24
-
25
- const findDebugLevel = nightingaleDebug.createFindDebugLevel(process.env.DEBUG);
26
- class ConsoleHandler {
27
- constructor(minLevel, options = {}) {
28
- this.minLevel = nightingaleLevels.Level.ALL;
29
- this.minLevel = minLevel;
30
-
31
- this.isHandling = (level, key) => level >= findDebugLevel(minLevel, key);
32
-
33
- this.handle = createHandle(options.formatter, options.output);
34
- }
35
-
36
- }
37
-
38
- exports.ConsoleHandler = ConsoleHandler;
39
- exports["default"] = ConsoleHandler;
40
- //# sourceMappingURL=index-node12-dev.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-node12-dev.cjs.js","sources":["../src/index.ts"],"sourcesContent":["import { POB_TARGET } from 'pob-babel';\nimport formatterANSI from 'nightingale-ansi-formatter';\nimport consoleOutput from 'nightingale-console-output';\nimport { createFindDebugLevel } from 'nightingale-debug';\nimport formatterJSON from 'nightingale-json-formatter';\nimport { Level } from 'nightingale-levels';\nimport type {\n IsHandling,\n Handle,\n LogRecord,\n Metadata,\n Handler,\n} from 'nightingale-types';\n\nconst defaultFormatter =\n POB_TARGET === 'node' &&\n !process.stdout.isTTY &&\n process.env.NIGHTINGALE_CONSOLE_FORMATTER !== 'ansi'\n ? formatterJSON\n : formatterANSI;\n\nconst createHandle = (\n formatter = defaultFormatter,\n output = consoleOutput,\n): Handle => {\n return <T extends Metadata>(record: LogRecord<T>): void => {\n output(formatter(record), record);\n };\n};\nconst findDebugLevel = createFindDebugLevel(process.env.DEBUG);\n\ninterface ConsoleHandlerOptions {\n formatter?: <T extends Metadata>(record: LogRecord<T>) => string;\n output?: <T extends Metadata>(\n param: string | string[],\n record: LogRecord<T>,\n ) => void;\n // compat with nightingale-app-console, not used yet\n theme?: 'dark' | 'light';\n}\n\nexport class ConsoleHandler implements Handler {\n minLevel: Level = Level.ALL;\n\n isHandling: IsHandling;\n\n handle: Handle;\n\n constructor(minLevel: Level, options: ConsoleHandlerOptions = {}) {\n this.minLevel = minLevel;\n this.isHandling = (level: Level, key: string) =>\n level >= findDebugLevel(minLevel, key);\n this.handle = createHandle(options.formatter, options.output);\n }\n}\n\n/** @deprecated use named export instead */\nexport default ConsoleHandler;\n"],"names":["defaultFormatter","process","stdout","isTTY","env","NIGHTINGALE_CONSOLE_FORMATTER","formatterJSON","formatterANSI","createHandle","formatter","output","consoleOutput","record","findDebugLevel","createFindDebugLevel","DEBUG","ConsoleHandler","constructor","minLevel","options","Level","ALL","isHandling","level","key","handle"],"mappings":";;;;;;;;;;;;;;;;AAcA,MAAMA,gBAAgB,GAEpB,CAACC,OAAO,CAACC,MAAR,CAAeC,KADhB,IAEAF,OAAO,CAACG,GAAR,CAAYC,6BAAZ,KAA8C,MAF9C,GAGIC,sBAHJ,GAIIC,sBALN;;AAOA,MAAMC,YAAY,GAAG,CACnBC,SAAS,GAAGT,gBADO,EAEnBU,MAAM,GAAGC,sBAFU,KAGR;AACX,SAA4BC,MAArB,IAAoD;AACzDF,IAAAA,MAAM,CAACD,SAAS,CAACG,MAAD,CAAV,EAAoBA,MAApB,CAAN;AACD,GAFD;AAGD,CAPD;;AAQA,MAAMC,cAAc,GAAGC,qCAAoB,CAACb,OAAO,CAACG,GAAR,CAAYW,KAAb,CAA3C;AAYO,MAAMC,cAAN,CAAwC;AAO7CC,EAAAA,WAAW,CAACC,QAAD,EAAkBC,OAA8B,GAAG,EAAnD,EAAuD;AAAA,SANlED,QAMkE,GANhDE,uBAAK,CAACC,GAM0C;AAChE,SAAKH,QAAL,GAAgBA,QAAhB;;AACA,SAAKI,UAAL,GAAkB,CAACC,KAAD,EAAeC,GAAf,KAChBD,KAAK,IAAIV,cAAc,CAACK,QAAD,EAAWM,GAAX,CADzB;;AAEA,SAAKC,MAAL,GAAcjB,YAAY,CAACW,OAAO,CAACV,SAAT,EAAoBU,OAAO,CAACT,MAA5B,CAA1B;AACD;;AAZ4C;;;;;"}
@@ -1,29 +0,0 @@
1
- import formatterANSI from 'nightingale-ansi-formatter';
2
- import consoleOutput from 'nightingale-console-output';
3
- import { createFindDebugLevel } from 'nightingale-debug';
4
- import formatterJSON from 'nightingale-json-formatter';
5
- import { Level } from 'nightingale-levels';
6
-
7
- const defaultFormatter = !process.stdout.isTTY && process.env.NIGHTINGALE_CONSOLE_FORMATTER !== 'ansi' ? formatterJSON : formatterANSI;
8
-
9
- const createHandle = (formatter = defaultFormatter, output = consoleOutput) => {
10
- return record => {
11
- output(formatter(record), record);
12
- };
13
- };
14
-
15
- const findDebugLevel = createFindDebugLevel(process.env.DEBUG);
16
- class ConsoleHandler {
17
- constructor(minLevel, options = {}) {
18
- this.minLevel = Level.ALL;
19
- this.minLevel = minLevel;
20
-
21
- this.isHandling = (level, key) => level >= findDebugLevel(minLevel, key);
22
-
23
- this.handle = createHandle(options.formatter, options.output);
24
- }
25
-
26
- }
27
-
28
- export { ConsoleHandler, ConsoleHandler as default };
29
- //# sourceMappingURL=index-node12-dev.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-node12-dev.mjs","sources":["../src/index.ts"],"sourcesContent":["import { POB_TARGET } from 'pob-babel';\nimport formatterANSI from 'nightingale-ansi-formatter';\nimport consoleOutput from 'nightingale-console-output';\nimport { createFindDebugLevel } from 'nightingale-debug';\nimport formatterJSON from 'nightingale-json-formatter';\nimport { Level } from 'nightingale-levels';\nimport type {\n IsHandling,\n Handle,\n LogRecord,\n Metadata,\n Handler,\n} from 'nightingale-types';\n\nconst defaultFormatter =\n POB_TARGET === 'node' &&\n !process.stdout.isTTY &&\n process.env.NIGHTINGALE_CONSOLE_FORMATTER !== 'ansi'\n ? formatterJSON\n : formatterANSI;\n\nconst createHandle = (\n formatter = defaultFormatter,\n output = consoleOutput,\n): Handle => {\n return <T extends Metadata>(record: LogRecord<T>): void => {\n output(formatter(record), record);\n };\n};\nconst findDebugLevel = createFindDebugLevel(process.env.DEBUG);\n\ninterface ConsoleHandlerOptions {\n formatter?: <T extends Metadata>(record: LogRecord<T>) => string;\n output?: <T extends Metadata>(\n param: string | string[],\n record: LogRecord<T>,\n ) => void;\n // compat with nightingale-app-console, not used yet\n theme?: 'dark' | 'light';\n}\n\nexport class ConsoleHandler implements Handler {\n minLevel: Level = Level.ALL;\n\n isHandling: IsHandling;\n\n handle: Handle;\n\n constructor(minLevel: Level, options: ConsoleHandlerOptions = {}) {\n this.minLevel = minLevel;\n this.isHandling = (level: Level, key: string) =>\n level >= findDebugLevel(minLevel, key);\n this.handle = createHandle(options.formatter, options.output);\n }\n}\n\n/** @deprecated use named export instead */\nexport default ConsoleHandler;\n"],"names":["defaultFormatter","process","stdout","isTTY","env","NIGHTINGALE_CONSOLE_FORMATTER","formatterJSON","formatterANSI","createHandle","formatter","output","consoleOutput","record","findDebugLevel","createFindDebugLevel","DEBUG","ConsoleHandler","constructor","minLevel","options","Level","ALL","isHandling","level","key","handle"],"mappings":";;;;;;AAcA,MAAMA,gBAAgB,GAEpB,CAACC,OAAO,CAACC,MAAR,CAAeC,KADhB,IAEAF,OAAO,CAACG,GAAR,CAAYC,6BAAZ,KAA8C,MAF9C,GAGIC,aAHJ,GAIIC,aALN;;AAOA,MAAMC,YAAY,GAAG,CACnBC,SAAS,GAAGT,gBADO,EAEnBU,MAAM,GAAGC,aAFU,KAGR;AACX,SAA4BC,MAArB,IAAoD;AACzDF,IAAAA,MAAM,CAACD,SAAS,CAACG,MAAD,CAAV,EAAoBA,MAApB,CAAN;AACD,GAFD;AAGD,CAPD;;AAQA,MAAMC,cAAc,GAAGC,oBAAoB,CAACb,OAAO,CAACG,GAAR,CAAYW,KAAb,CAA3C;AAYO,MAAMC,cAAN,CAAwC;AAO7CC,EAAAA,WAAW,CAACC,QAAD,EAAkBC,OAA8B,GAAG,EAAnD,EAAuD;AAAA,SANlED,QAMkE,GANhDE,KAAK,CAACC,GAM0C;AAChE,SAAKH,QAAL,GAAgBA,QAAhB;;AACA,SAAKI,UAAL,GAAkB,CAACC,KAAD,EAAeC,GAAf,KAChBD,KAAK,IAAIV,cAAc,CAACK,QAAD,EAAWM,GAAX,CADzB;;AAEA,SAAKC,MAAL,GAAcjB,YAAY,CAACW,OAAO,CAACV,SAAT,EAAoBU,OAAO,CAACT,MAA5B,CAA1B;AACD;;AAZ4C;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-node12.cjs.js","sources":["../src/index.ts"],"sourcesContent":["import { POB_TARGET } from 'pob-babel';\nimport formatterANSI from 'nightingale-ansi-formatter';\nimport consoleOutput from 'nightingale-console-output';\nimport { createFindDebugLevel } from 'nightingale-debug';\nimport formatterJSON from 'nightingale-json-formatter';\nimport { Level } from 'nightingale-levels';\nimport type {\n IsHandling,\n Handle,\n LogRecord,\n Metadata,\n Handler,\n} from 'nightingale-types';\n\nconst defaultFormatter =\n POB_TARGET === 'node' &&\n !process.stdout.isTTY &&\n process.env.NIGHTINGALE_CONSOLE_FORMATTER !== 'ansi'\n ? formatterJSON\n : formatterANSI;\n\nconst createHandle = (\n formatter = defaultFormatter,\n output = consoleOutput,\n): Handle => {\n return <T extends Metadata>(record: LogRecord<T>): void => {\n output(formatter(record), record);\n };\n};\nconst findDebugLevel = createFindDebugLevel(process.env.DEBUG);\n\ninterface ConsoleHandlerOptions {\n formatter?: <T extends Metadata>(record: LogRecord<T>) => string;\n output?: <T extends Metadata>(\n param: string | string[],\n record: LogRecord<T>,\n ) => void;\n // compat with nightingale-app-console, not used yet\n theme?: 'dark' | 'light';\n}\n\nexport class ConsoleHandler implements Handler {\n minLevel: Level = Level.ALL;\n\n isHandling: IsHandling;\n\n handle: Handle;\n\n constructor(minLevel: Level, options: ConsoleHandlerOptions = {}) {\n this.minLevel = minLevel;\n this.isHandling = (level: Level, key: string) =>\n level >= findDebugLevel(minLevel, key);\n this.handle = createHandle(options.formatter, options.output);\n }\n}\n\n/** @deprecated use named export instead */\nexport default ConsoleHandler;\n"],"names":["defaultFormatter","process","stdout","isTTY","env","NIGHTINGALE_CONSOLE_FORMATTER","formatterJSON","formatterANSI","createHandle","formatter","output","consoleOutput","record","findDebugLevel","createFindDebugLevel","DEBUG","ConsoleHandler","constructor","minLevel","options","Level","ALL","isHandling","level","key","handle"],"mappings":";;;;;;;;;;;;;;;;AAcA,MAAMA,gBAAgB,GAEpB,CAACC,OAAO,CAACC,MAAR,CAAeC,KADhB,IAEAF,OAAO,CAACG,GAAR,CAAYC,6BAAZ,KAA8C,MAF9C,GAGIC,sBAHJ,GAIIC,sBALN;;AAOA,MAAMC,YAAY,GAAG,CACnBC,SAAS,GAAGT,gBADO,EAEnBU,MAAM,GAAGC,sBAFU,KAGR;AACX,SAA4BC,MAArB,IAAoD;AACzDF,IAAAA,MAAM,CAACD,SAAS,CAACG,MAAD,CAAV,EAAoBA,MAApB,CAAN;AACD,GAFD;AAGD,CAPD;;AAQA,MAAMC,cAAc,GAAGC,qCAAoB,CAACb,OAAO,CAACG,GAAR,CAAYW,KAAb,CAA3C;AAYO,MAAMC,cAAN,CAAwC;AAO7CC,EAAAA,WAAW,CAACC,QAAD,EAAkBC,OAA8B,GAAG,EAAnD,EAAuD;AAAA,SANlED,QAMkE,GANhDE,uBAAK,CAACC,GAM0C;AAChE,SAAKH,QAAL,GAAgBA,QAAhB;;AACA,SAAKI,UAAL,GAAkB,CAACC,KAAD,EAAeC,GAAf,KAChBD,KAAK,IAAIV,cAAc,CAACK,QAAD,EAAWM,GAAX,CADzB;;AAEA,SAAKC,MAAL,GAAcjB,YAAY,CAACW,OAAO,CAACV,SAAT,EAAoBU,OAAO,CAACT,MAA5B,CAA1B;AACD;;AAZ4C;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-node12.mjs","sources":["../src/index.ts"],"sourcesContent":["import { POB_TARGET } from 'pob-babel';\nimport formatterANSI from 'nightingale-ansi-formatter';\nimport consoleOutput from 'nightingale-console-output';\nimport { createFindDebugLevel } from 'nightingale-debug';\nimport formatterJSON from 'nightingale-json-formatter';\nimport { Level } from 'nightingale-levels';\nimport type {\n IsHandling,\n Handle,\n LogRecord,\n Metadata,\n Handler,\n} from 'nightingale-types';\n\nconst defaultFormatter =\n POB_TARGET === 'node' &&\n !process.stdout.isTTY &&\n process.env.NIGHTINGALE_CONSOLE_FORMATTER !== 'ansi'\n ? formatterJSON\n : formatterANSI;\n\nconst createHandle = (\n formatter = defaultFormatter,\n output = consoleOutput,\n): Handle => {\n return <T extends Metadata>(record: LogRecord<T>): void => {\n output(formatter(record), record);\n };\n};\nconst findDebugLevel = createFindDebugLevel(process.env.DEBUG);\n\ninterface ConsoleHandlerOptions {\n formatter?: <T extends Metadata>(record: LogRecord<T>) => string;\n output?: <T extends Metadata>(\n param: string | string[],\n record: LogRecord<T>,\n ) => void;\n // compat with nightingale-app-console, not used yet\n theme?: 'dark' | 'light';\n}\n\nexport class ConsoleHandler implements Handler {\n minLevel: Level = Level.ALL;\n\n isHandling: IsHandling;\n\n handle: Handle;\n\n constructor(minLevel: Level, options: ConsoleHandlerOptions = {}) {\n this.minLevel = minLevel;\n this.isHandling = (level: Level, key: string) =>\n level >= findDebugLevel(minLevel, key);\n this.handle = createHandle(options.formatter, options.output);\n }\n}\n\n/** @deprecated use named export instead */\nexport default ConsoleHandler;\n"],"names":["defaultFormatter","process","stdout","isTTY","env","NIGHTINGALE_CONSOLE_FORMATTER","formatterJSON","formatterANSI","createHandle","formatter","output","consoleOutput","record","findDebugLevel","createFindDebugLevel","DEBUG","ConsoleHandler","constructor","minLevel","options","Level","ALL","isHandling","level","key","handle"],"mappings":";;;;;;AAcA,MAAMA,gBAAgB,GAEpB,CAACC,OAAO,CAACC,MAAR,CAAeC,KADhB,IAEAF,OAAO,CAACG,GAAR,CAAYC,6BAAZ,KAA8C,MAF9C,GAGIC,aAHJ,GAIIC,aALN;;AAOA,MAAMC,YAAY,GAAG,CACnBC,SAAS,GAAGT,gBADO,EAEnBU,MAAM,GAAGC,aAFU,KAGR;AACX,SAA4BC,MAArB,IAAoD;AACzDF,IAAAA,MAAM,CAACD,SAAS,CAACG,MAAD,CAAV,EAAoBA,MAApB,CAAN;AACD,GAFD;AAGD,CAPD;;AAQA,MAAMC,cAAc,GAAGC,oBAAoB,CAACb,OAAO,CAACG,GAAR,CAAYW,KAAb,CAA3C;AAYO,MAAMC,cAAN,CAAwC;AAO7CC,EAAAA,WAAW,CAACC,QAAD,EAAkBC,OAA8B,GAAG,EAAnD,EAAuD;AAAA,SANlED,QAMkE,GANhDE,KAAK,CAACC,GAM0C;AAChE,SAAKH,QAAL,GAAgBA,QAAhB;;AACA,SAAKI,UAAL,GAAkB,CAACC,KAAD,EAAeC,GAAf,KAChBD,KAAK,IAAIV,cAAc,CAACK,QAAD,EAAWM,GAAX,CADzB;;AAEA,SAAKC,MAAL,GAAcjB,YAAY,CAACW,OAAO,CAACV,SAAT,EAAoBU,OAAO,CAACT,MAA5B,CAA1B;AACD;;AAZ4C;;;;"}