@lolyjs/core 0.2.0-alpha.25 → 0.2.0-alpha.27
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/cli.cjs +21 -6
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +21 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +21 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -8
- package/dist/index.js.map +1 -1
- package/dist/runtime.cjs +0 -2
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +0 -2
- package/dist/runtime.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -13642,7 +13642,7 @@ var DEFAULT_REALTIME_CONFIG = {
|
|
|
13642
13642
|
burst: 60
|
|
13643
13643
|
},
|
|
13644
13644
|
logging: {
|
|
13645
|
-
level: "info",
|
|
13645
|
+
level: process.env.NODE_ENV === "production" ? "warn" : "info",
|
|
13646
13646
|
pretty: process.env.NODE_ENV !== "production"
|
|
13647
13647
|
}
|
|
13648
13648
|
};
|
|
@@ -17112,13 +17112,24 @@ function validateSchema(schema, data) {
|
|
|
17112
17112
|
}
|
|
17113
17113
|
|
|
17114
17114
|
// modules/realtime/logging/index.ts
|
|
17115
|
-
|
|
17115
|
+
var LOG_LEVELS = {
|
|
17116
|
+
debug: 0,
|
|
17117
|
+
info: 1,
|
|
17118
|
+
warn: 2,
|
|
17119
|
+
error: 3
|
|
17120
|
+
};
|
|
17121
|
+
function createWssLogger(namespace, socket, baseLogger, minLevel = "info") {
|
|
17116
17122
|
const context = {
|
|
17117
17123
|
namespace,
|
|
17118
17124
|
socketId: socket.id,
|
|
17119
17125
|
userId: socket.data?.user?.id || null
|
|
17120
17126
|
};
|
|
17127
|
+
const minLevelNum = LOG_LEVELS[minLevel] ?? LOG_LEVELS.info;
|
|
17121
17128
|
const log = (level, message, meta) => {
|
|
17129
|
+
const levelNum = LOG_LEVELS[level] ?? LOG_LEVELS.info;
|
|
17130
|
+
if (levelNum < minLevelNum) {
|
|
17131
|
+
return;
|
|
17132
|
+
}
|
|
17122
17133
|
const fullMeta = {
|
|
17123
17134
|
...context,
|
|
17124
17135
|
...meta,
|
|
@@ -17305,7 +17316,8 @@ async function setupWssEvents(options) {
|
|
|
17305
17316
|
namespace.on("connection", async (socket) => {
|
|
17306
17317
|
const requestId = generateRequestId();
|
|
17307
17318
|
socket.requestId = requestId;
|
|
17308
|
-
const
|
|
17319
|
+
const logLevel = realtimeConfig.logging?.level || (process.env.NODE_ENV === "production" ? "warn" : "info");
|
|
17320
|
+
const log = createWssLogger(namespacePath, socket, void 0, logLevel);
|
|
17309
17321
|
try {
|
|
17310
17322
|
const user = await executeAuth(normalized.auth, socket, namespacePath);
|
|
17311
17323
|
socket.data = socket.data || {};
|
|
@@ -17340,7 +17352,8 @@ async function setupWssEvents(options) {
|
|
|
17340
17352
|
socket.on(eventName, async (data) => {
|
|
17341
17353
|
const eventRequestId = generateRequestId();
|
|
17342
17354
|
socket.requestId = eventRequestId;
|
|
17343
|
-
const
|
|
17355
|
+
const eventLogLevel = realtimeConfig.logging?.level || (process.env.NODE_ENV === "production" ? "warn" : "info");
|
|
17356
|
+
const eventLog = createWssLogger(namespacePath, socket, void 0, eventLogLevel);
|
|
17344
17357
|
eventLog.debug(`Event received: ${eventName}`, { data });
|
|
17345
17358
|
try {
|
|
17346
17359
|
const ctx = {
|
|
@@ -17398,7 +17411,8 @@ async function setupWssEvents(options) {
|
|
|
17398
17411
|
await eventDef.handler(ctx);
|
|
17399
17412
|
eventLog.debug(`Event handled: ${eventName}`);
|
|
17400
17413
|
} catch (error) {
|
|
17401
|
-
const
|
|
17414
|
+
const errorLogLevel = realtimeConfig.logging?.level || (process.env.NODE_ENV === "production" ? "warn" : "info");
|
|
17415
|
+
const errorLog = createWssLogger(namespacePath, socket, void 0, errorLogLevel);
|
|
17402
17416
|
errorLog.error(`Error handling event ${eventName}`, {
|
|
17403
17417
|
error: error instanceof Error ? error.message : String(error),
|
|
17404
17418
|
stack: error instanceof Error ? error.stack : void 0
|
|
@@ -17418,9 +17432,10 @@ async function setupWssEvents(options) {
|
|
|
17418
17432
|
}
|
|
17419
17433
|
if (normalized.onDisconnect) {
|
|
17420
17434
|
try {
|
|
17435
|
+
const disconnectLogLevel = realtimeConfig.logging?.level || (process.env.NODE_ENV === "production" ? "warn" : "info");
|
|
17421
17436
|
const disconnectCtx = {
|
|
17422
17437
|
...baseCtx,
|
|
17423
|
-
log: createWssLogger(namespacePath, socket)
|
|
17438
|
+
log: createWssLogger(namespacePath, socket, void 0, disconnectLogLevel)
|
|
17424
17439
|
};
|
|
17425
17440
|
await normalized.onDisconnect(disconnectCtx, reason);
|
|
17426
17441
|
} catch (error) {
|