@ttoss/logger 0.6.3 → 0.6.5
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/dist/esm/index.js +15 -10
- package/dist/index.js +14 -10
- package/package.json +3 -3
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", {
|
|
4
|
+
value,
|
|
5
|
+
configurable: true
|
|
6
|
+
});
|
|
2
7
|
|
|
3
8
|
// src/index.ts
|
|
4
9
|
var log = {
|
|
@@ -7,10 +12,10 @@ var log = {
|
|
|
7
12
|
info: console.info
|
|
8
13
|
};
|
|
9
14
|
var setup = null;
|
|
10
|
-
var configureLogger = params => {
|
|
15
|
+
var configureLogger = /* @__PURE__ */__name(params => {
|
|
11
16
|
setup = params;
|
|
12
|
-
};
|
|
13
|
-
var sendNotificationToDiscord = async ({
|
|
17
|
+
}, "configureLogger");
|
|
18
|
+
var sendNotificationToDiscord = /* @__PURE__ */__name(async ({
|
|
14
19
|
notification,
|
|
15
20
|
url,
|
|
16
21
|
project
|
|
@@ -33,8 +38,8 @@ var sendNotificationToDiscord = async ({
|
|
|
33
38
|
},
|
|
34
39
|
body
|
|
35
40
|
});
|
|
36
|
-
};
|
|
37
|
-
var notify = async notification => {
|
|
41
|
+
}, "sendNotificationToDiscord");
|
|
42
|
+
var notify = /* @__PURE__ */__name(async notification => {
|
|
38
43
|
if (notification.log) {
|
|
39
44
|
const message = [notification.title, notification.message].join(": ");
|
|
40
45
|
log[notification.type](message);
|
|
@@ -49,8 +54,8 @@ var notify = async notification => {
|
|
|
49
54
|
project: setup.project
|
|
50
55
|
});
|
|
51
56
|
}
|
|
52
|
-
};
|
|
53
|
-
var getErrorMessage = error => {
|
|
57
|
+
}, "notify");
|
|
58
|
+
var getErrorMessage = /* @__PURE__ */__name(error => {
|
|
54
59
|
if (error instanceof Error) {
|
|
55
60
|
return error.message;
|
|
56
61
|
}
|
|
@@ -58,13 +63,13 @@ var getErrorMessage = error => {
|
|
|
58
63
|
return error;
|
|
59
64
|
}
|
|
60
65
|
return "Unknown error:" + JSON.stringify(error);
|
|
61
|
-
};
|
|
62
|
-
var notifyError = async notification => {
|
|
66
|
+
}, "getErrorMessage");
|
|
67
|
+
var notifyError = /* @__PURE__ */__name(async notification => {
|
|
63
68
|
return notify({
|
|
64
69
|
type: "error",
|
|
65
70
|
message: getErrorMessage(notification.error),
|
|
66
71
|
title: notification.title,
|
|
67
72
|
log: notification.log
|
|
68
73
|
});
|
|
69
|
-
};
|
|
74
|
+
}, "notifyError");
|
|
70
75
|
export { configureLogger, log, notify, notifyError, sendNotificationToDiscord };
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,10 @@ var __defProp = Object.defineProperty;
|
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", {
|
|
9
|
+
value,
|
|
10
|
+
configurable: true
|
|
11
|
+
});
|
|
8
12
|
var __export = (target, all) => {
|
|
9
13
|
for (var name in all) __defProp(target, name, {
|
|
10
14
|
get: all[name],
|
|
@@ -40,10 +44,10 @@ var log = {
|
|
|
40
44
|
info: console.info
|
|
41
45
|
};
|
|
42
46
|
var setup = null;
|
|
43
|
-
var configureLogger = params => {
|
|
47
|
+
var configureLogger = /* @__PURE__ */__name(params => {
|
|
44
48
|
setup = params;
|
|
45
|
-
};
|
|
46
|
-
var sendNotificationToDiscord = async ({
|
|
49
|
+
}, "configureLogger");
|
|
50
|
+
var sendNotificationToDiscord = /* @__PURE__ */__name(async ({
|
|
47
51
|
notification,
|
|
48
52
|
url,
|
|
49
53
|
project
|
|
@@ -66,8 +70,8 @@ var sendNotificationToDiscord = async ({
|
|
|
66
70
|
},
|
|
67
71
|
body
|
|
68
72
|
});
|
|
69
|
-
};
|
|
70
|
-
var notify = async notification => {
|
|
73
|
+
}, "sendNotificationToDiscord");
|
|
74
|
+
var notify = /* @__PURE__ */__name(async notification => {
|
|
71
75
|
if (notification.log) {
|
|
72
76
|
const message = [notification.title, notification.message].join(": ");
|
|
73
77
|
log[notification.type](message);
|
|
@@ -82,8 +86,8 @@ var notify = async notification => {
|
|
|
82
86
|
project: setup.project
|
|
83
87
|
});
|
|
84
88
|
}
|
|
85
|
-
};
|
|
86
|
-
var getErrorMessage = error => {
|
|
89
|
+
}, "notify");
|
|
90
|
+
var getErrorMessage = /* @__PURE__ */__name(error => {
|
|
87
91
|
if (error instanceof Error) {
|
|
88
92
|
return error.message;
|
|
89
93
|
}
|
|
@@ -91,15 +95,15 @@ var getErrorMessage = error => {
|
|
|
91
95
|
return error;
|
|
92
96
|
}
|
|
93
97
|
return "Unknown error:" + JSON.stringify(error);
|
|
94
|
-
};
|
|
95
|
-
var notifyError = async notification => {
|
|
98
|
+
}, "getErrorMessage");
|
|
99
|
+
var notifyError = /* @__PURE__ */__name(async notification => {
|
|
96
100
|
return notify({
|
|
97
101
|
type: "error",
|
|
98
102
|
message: getErrorMessage(notification.error),
|
|
99
103
|
title: notification.title,
|
|
100
104
|
log: notification.log
|
|
101
105
|
});
|
|
102
|
-
};
|
|
106
|
+
}, "notifyError");
|
|
103
107
|
// Annotate the CommonJS export names for ESM import in node:
|
|
104
108
|
0 && (module.exports = {
|
|
105
109
|
configureLogger,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/logger",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5",
|
|
4
4
|
"description": "A simple module to configure and send notifications to services like Discord from your applications.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"contributors": [],
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"jest": "^30.0.4",
|
|
25
25
|
"tsup": "^8.5.0",
|
|
26
|
-
"@ttoss/
|
|
27
|
-
"@ttoss/
|
|
26
|
+
"@ttoss/config": "^1.35.7",
|
|
27
|
+
"@ttoss/test-utils": "^2.1.27"
|
|
28
28
|
},
|
|
29
29
|
"keywords": [],
|
|
30
30
|
"publishConfig": {
|