@onesub/server 0.23.0 → 0.23.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/dist/__tests__/logger.test.d.ts +11 -0
- package/dist/__tests__/logger.test.d.ts.map +1 -0
- package/dist/index.cjs +13 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -168,10 +168,20 @@ var current = console;
|
|
|
168
168
|
function setLogger(logger) {
|
|
169
169
|
if (logger) current = logger;
|
|
170
170
|
}
|
|
171
|
+
function escapeLineBreaks(value) {
|
|
172
|
+
return value.replace(/[\r\n\u2028\u2029]/g, (ch) => {
|
|
173
|
+
if (ch === "\n") return "\\n";
|
|
174
|
+
if (ch === "\r") return "\\r";
|
|
175
|
+
return `\\u${ch.charCodeAt(0).toString(16).padStart(4, "0")}`;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
function scrub(args) {
|
|
179
|
+
return args.map((arg) => typeof arg === "string" ? escapeLineBreaks(arg) : arg);
|
|
180
|
+
}
|
|
171
181
|
var log = {
|
|
172
|
-
info: (...args) => current.info(...args),
|
|
173
|
-
warn: (...args) => current.warn(...args),
|
|
174
|
-
error: (...args) => current.error(...args)
|
|
182
|
+
info: (...args) => current.info(...scrub(args)),
|
|
183
|
+
warn: (...args) => current.warn(...scrub(args)),
|
|
184
|
+
error: (...args) => current.error(...scrub(args))
|
|
175
185
|
};
|
|
176
186
|
|
|
177
187
|
// src/http.ts
|