@graphql-markdown/logger 1.0.0-next.0
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/LICENSE +21 -0
- package/README.md +4 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +58 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Grégory Heitz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# @graphql-markdown/logger
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@graphql-markdown/logger)
|
|
4
|
+
[](https://raw.githubusercontent.com/graphql-markdown/graphql-markdown/main/LICENSE)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger singleton module.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { LoggerType, Maybe } from "@graphql-markdown/types";
|
|
7
|
+
declare global {
|
|
8
|
+
var logger: Maybe<LoggerType>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Returns a logger module, if a package name is provided then instantiates it.
|
|
12
|
+
* By default, the logger module uses `global.console`
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*
|
|
16
|
+
* @param moduleName - optional name of the logger package.
|
|
17
|
+
*
|
|
18
|
+
* @returns an instance of the logger.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```js
|
|
22
|
+
* import { Logger } from "@graphql-markdown/utils/logger";
|
|
23
|
+
*
|
|
24
|
+
* Logger().info("Info message"); // Expected console output "Info message"
|
|
25
|
+
*
|
|
26
|
+
* const loggerModule = require.resolve("@docusaurus/logger");
|
|
27
|
+
* Logger(loggerModule).info("Info message"); // Expected Docusaurus log output "Info message"
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
export declare const Logger: (moduleName?: string) => LoggerType;
|
|
32
|
+
export default Logger;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Logger singleton module.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.Logger = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* Returns a logger module, if a package name is provided then instantiates it.
|
|
11
|
+
* By default, the logger module uses `global.console`
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*
|
|
15
|
+
* @param moduleName - optional name of the logger package.
|
|
16
|
+
*
|
|
17
|
+
* @returns an instance of the logger.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```js
|
|
21
|
+
* import { Logger } from "@graphql-markdown/utils/logger";
|
|
22
|
+
*
|
|
23
|
+
* Logger().info("Info message"); // Expected console output "Info message"
|
|
24
|
+
*
|
|
25
|
+
* const loggerModule = require.resolve("@docusaurus/logger");
|
|
26
|
+
* Logger(loggerModule).info("Info message"); // Expected Docusaurus log output "Info message"
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
const Logger = (moduleName) => {
|
|
31
|
+
if (global.logger && typeof moduleName === "undefined") {
|
|
32
|
+
return global.logger;
|
|
33
|
+
}
|
|
34
|
+
if (typeof moduleName !== "string" || moduleName === "") {
|
|
35
|
+
global.logger = global.console;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
global.logger = require(moduleName);
|
|
39
|
+
}
|
|
40
|
+
if (typeof global.logger.log === "undefined") {
|
|
41
|
+
global.logger.log = (...args) => global.logger.info.apply(null, args);
|
|
42
|
+
}
|
|
43
|
+
if (typeof global.logger.success === "undefined") {
|
|
44
|
+
global.logger.success = (...args) => global.logger.info.apply(null, args);
|
|
45
|
+
}
|
|
46
|
+
if (typeof global.logger.debug === "undefined") {
|
|
47
|
+
global.logger.debug = (...args) => global.logger.info.apply(null, args);
|
|
48
|
+
}
|
|
49
|
+
if (typeof global.logger.warn === "undefined") {
|
|
50
|
+
global.logger.warn = (...args) => global.logger.info.apply(null, args);
|
|
51
|
+
}
|
|
52
|
+
if (typeof global.logger.error === "undefined") {
|
|
53
|
+
global.logger.error = (...args) => global.logger.info.apply(null, args);
|
|
54
|
+
}
|
|
55
|
+
return global.logger;
|
|
56
|
+
};
|
|
57
|
+
exports.Logger = Logger;
|
|
58
|
+
exports.default = exports.Logger;
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@graphql-markdown/logger",
|
|
3
|
+
"homepage": "https://graphql-markdown.github.io",
|
|
4
|
+
"description": "GraphQL-Markdown logger.",
|
|
5
|
+
"bugs": {
|
|
6
|
+
"url": "https://github.com/graphql-markdown/graphql-markdown/issues"
|
|
7
|
+
},
|
|
8
|
+
"version": "1.0.0-next.0",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "graphql-markdown/graphql-markdown",
|
|
13
|
+
"directory": "packages/logger"
|
|
14
|
+
},
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Gregory Heitz"
|
|
17
|
+
},
|
|
18
|
+
"main": "dist/index.js",
|
|
19
|
+
"types": "dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"require": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"import": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"default": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"default": "./dist/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"./package.json": "./package.json"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"prepack": "pinst --disable",
|
|
39
|
+
"postpack": "pinst --enable",
|
|
40
|
+
"stryker": "stryker run",
|
|
41
|
+
"clean": "rm -rf ./dist",
|
|
42
|
+
"docs": "typedoc"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@graphql-markdown/types": "^1.0.0-next.0"
|
|
46
|
+
},
|
|
47
|
+
"directories": {
|
|
48
|
+
"test": "tests"
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=16.14"
|
|
52
|
+
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"directory": "dist",
|
|
55
|
+
"access": "public"
|
|
56
|
+
},
|
|
57
|
+
"typescript": {
|
|
58
|
+
"definition": "dist/index.d.ts"
|
|
59
|
+
},
|
|
60
|
+
"files": [
|
|
61
|
+
"dist"
|
|
62
|
+
]
|
|
63
|
+
}
|