@fonoster/logger 0.5.5 → 0.6.1-alpha.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 +2 -2
- package/README.md +3 -0
- package/dist/envs.js +4 -4
- package/dist/getLogger.d.ts +5 -0
- package/dist/{get_logger.js → getLogger.js} +20 -10
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -6
- package/dist/userLogger.js +33 -0
- package/package.json +3 -8
- package/dist/get_logger.d.ts +0 -5
- package/dist/user_logger.js +0 -15
- /package/dist/{user_logger.d.ts → userLogger.d.ts} +0 -0
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2024 Fonoster Inc
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<a href="https://gitpod.io/#https://github.com/fonoster/fonoster"> <img src="https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod" alt="Contribute with Gitpod" />
|
|
2
|
+
|
|
3
|
+
This module is part of the [Fonoster](https://fonoster.com) project. By itself, it does not do much. It is intended to be used as a dependency for other modules. For more information about the project, please visit [https://github.com/fonoster/fonoster](https://github.com/fonoster/fonoster).
|
package/dist/envs.js
CHANGED
|
@@ -22,17 +22,17 @@ exports.fluent = exports.transports = exports.level = exports.format = void 0;
|
|
|
22
22
|
* See the License for the specific language governing permissions and
|
|
23
23
|
* limitations under the License.
|
|
24
24
|
*/
|
|
25
|
-
const winston_1 = __importDefault(require("winston"));
|
|
26
25
|
const fluent_logger_1 = __importDefault(require("fluent-logger"));
|
|
27
|
-
const
|
|
26
|
+
const winston_1 = __importDefault(require("winston"));
|
|
27
|
+
const FluentTransport = fluent_logger_1.default.support.winstonTransport();
|
|
28
28
|
const LOGS_DRIVER_HOST = process.env.LOGS_DRIVER_HOST;
|
|
29
29
|
const LOGS_DRIVER_PORT = process.env.LOGS_DRIVER_PORT || 24224;
|
|
30
30
|
const LOGS_OPT_TAG_PREFIX = process.env.LOGS_OPT_TAG_PREFIX || "fonoster-logs";
|
|
31
31
|
const LOGS_FORMAT = process.env.LOGS_FORMAT || "json";
|
|
32
32
|
const LOGS_LEVEL = process.env.LOGS_LEVEL || "info";
|
|
33
33
|
exports.level = LOGS_LEVEL;
|
|
34
|
-
const LOGS_TRANSPORT = process.env.LOGS_TRANSPORT || "
|
|
35
|
-
const fluent = new
|
|
34
|
+
const LOGS_TRANSPORT = process.env.LOGS_TRANSPORT || "console";
|
|
35
|
+
const fluent = new FluentTransport(`${LOGS_OPT_TAG_PREFIX}`, {
|
|
36
36
|
host: LOGS_DRIVER_HOST,
|
|
37
37
|
port: LOGS_DRIVER_PORT,
|
|
38
38
|
timeout: 3.0,
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
15
|
};
|
|
5
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
17
|
+
exports.getLogger = void 0;
|
|
7
18
|
/*
|
|
8
19
|
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
9
20
|
* http://github.com/fonoster/fonoster
|
|
@@ -22,19 +33,20 @@ exports.default = exports.getLogger = void 0;
|
|
|
22
33
|
* See the License for the specific language governing permissions and
|
|
23
34
|
* limitations under the License.
|
|
24
35
|
*/
|
|
25
|
-
const path_1 = require("path");
|
|
26
|
-
const envs_1 = require("./envs");
|
|
27
36
|
const winston_1 = __importDefault(require("winston"));
|
|
37
|
+
const envs_1 = require("./envs");
|
|
28
38
|
const loggers = new Map();
|
|
29
|
-
|
|
30
|
-
const key =
|
|
39
|
+
function getLogger(config) {
|
|
40
|
+
const key = config.service || "default";
|
|
31
41
|
if (loggers.has(key)) {
|
|
32
42
|
return loggers.get(key);
|
|
33
43
|
}
|
|
34
|
-
const file = config.filePath.replace((0, path_1.resolve)("./"), "");
|
|
35
44
|
const humanFormat = winston_1.default.format.combine(winston_1.default.format.timestamp({
|
|
36
45
|
format: "YYYY-MM-dd HH:mm:ss.SSS"
|
|
37
|
-
}), winston_1.default.format.printf((
|
|
46
|
+
}), winston_1.default.format.printf((_a) => {
|
|
47
|
+
var { level, message, timestamp } = _a, metadata = __rest(_a, ["level", "message", "timestamp"]);
|
|
48
|
+
return `${timestamp} [${level}]: ${config.service ? `(${config.service})` : ""} ${message} ${JSON.stringify(metadata)}`;
|
|
49
|
+
}));
|
|
38
50
|
const newLogger = winston_1.default.createLogger({
|
|
39
51
|
levels: winston_1.default.config.npm.levels,
|
|
40
52
|
format: humanFormat,
|
|
@@ -44,9 +56,7 @@ const getLogger = (config) => {
|
|
|
44
56
|
newLogger.on("finish", () => {
|
|
45
57
|
envs_1.fluent.sender.end("end", {}, () => { });
|
|
46
58
|
});
|
|
47
|
-
// Store the new logger in the map
|
|
48
59
|
loggers.set(key, newLogger);
|
|
49
60
|
return newLogger;
|
|
50
|
-
}
|
|
61
|
+
}
|
|
51
62
|
exports.getLogger = getLogger;
|
|
52
|
-
exports.default = exports.getLogger;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getLogger } from "./getLogger";
|
|
2
2
|
import logger, { mute, unmute } from "./logger";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import { ULogType } from "./types";
|
|
4
|
+
import ulogger from "./userLogger";
|
|
5
5
|
export { logger as default, getLogger, ulogger, ULogType, mute, unmute };
|
package/dist/index.js
CHANGED
|
@@ -45,13 +45,13 @@ exports.unmute = exports.mute = exports.ULogType = exports.ulogger = exports.get
|
|
|
45
45
|
* See the License for the specific language governing permissions and
|
|
46
46
|
* limitations under the License.
|
|
47
47
|
*/
|
|
48
|
-
const
|
|
49
|
-
Object.defineProperty(exports, "
|
|
48
|
+
const getLogger_1 = require("./getLogger");
|
|
49
|
+
Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return getLogger_1.getLogger; } });
|
|
50
50
|
const logger_1 = __importStar(require("./logger"));
|
|
51
51
|
exports.default = logger_1.default;
|
|
52
52
|
Object.defineProperty(exports, "mute", { enumerable: true, get: function () { return logger_1.mute; } });
|
|
53
53
|
Object.defineProperty(exports, "unmute", { enumerable: true, get: function () { return logger_1.unmute; } });
|
|
54
|
-
const
|
|
55
|
-
exports
|
|
56
|
-
const
|
|
57
|
-
exports.
|
|
54
|
+
const types_1 = require("./types");
|
|
55
|
+
Object.defineProperty(exports, "ULogType", { enumerable: true, get: function () { return types_1.ULogType; } });
|
|
56
|
+
const userLogger_1 = __importDefault(require("./userLogger"));
|
|
57
|
+
exports.ulogger = userLogger_1.default;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
9
|
+
* http://github.com/fonoster/fonoster
|
|
10
|
+
*
|
|
11
|
+
* This file is part of Fonoster
|
|
12
|
+
*
|
|
13
|
+
* Licensed under the MIT License (the "License");
|
|
14
|
+
* you may not use this file except in compliance with
|
|
15
|
+
* the License. You may obtain a copy of the License at
|
|
16
|
+
*
|
|
17
|
+
* https://opensource.org/licenses/MIT
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
+
* See the License for the specific language governing permissions and
|
|
23
|
+
* limitations under the License.
|
|
24
|
+
*/
|
|
25
|
+
const logger_1 = __importDefault(require("./logger"));
|
|
26
|
+
// Special logger function for User specific events
|
|
27
|
+
const ulogger = (log) => logger_1.default[log.level](log.message, {
|
|
28
|
+
eventType: log.eventType,
|
|
29
|
+
body: log.body,
|
|
30
|
+
level: log.level,
|
|
31
|
+
accessKeyId: log.accessKeyId
|
|
32
|
+
});
|
|
33
|
+
exports.default = ulogger;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/logger",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1-alpha.0",
|
|
4
4
|
"description": "Logger module",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -30,12 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"fluent-logger": "^3.4.1",
|
|
33
|
-
"winston": "^3.
|
|
33
|
+
"winston": "^3.13.0"
|
|
34
34
|
},
|
|
35
|
-
"
|
|
36
|
-
"@types/node": "^18.15.11",
|
|
37
|
-
"rimraf": "^3.0.2",
|
|
38
|
-
"typescript": "^4.1.3"
|
|
39
|
-
},
|
|
40
|
-
"gitHead": "4a1438d9dedeaf7b2a5b6a50d5e233f994e2b2cf"
|
|
35
|
+
"gitHead": "2cdd1508146747550fe048c35d9a010d04f6d3aa"
|
|
41
36
|
}
|
package/dist/get_logger.d.ts
DELETED
package/dist/user_logger.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
const logger_1 = __importDefault(require("./logger"));
|
|
8
|
-
// Special logger function for User specific events
|
|
9
|
-
const ulogger = (log) => logger_1.default[log.level](log.message, {
|
|
10
|
-
eventType: log.eventType,
|
|
11
|
-
body: log.body,
|
|
12
|
-
level: log.level,
|
|
13
|
-
accessKeyId: log.accessKeyId
|
|
14
|
-
});
|
|
15
|
-
exports.default = ulogger;
|
|
File without changes
|