@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.cjs
CHANGED
|
@@ -13637,7 +13637,7 @@ var DEFAULT_REALTIME_CONFIG = {
|
|
|
13637
13637
|
burst: 60
|
|
13638
13638
|
},
|
|
13639
13639
|
logging: {
|
|
13640
|
-
level: "info",
|
|
13640
|
+
level: process.env.NODE_ENV === "production" ? "warn" : "info",
|
|
13641
13641
|
pretty: process.env.NODE_ENV !== "production"
|
|
13642
13642
|
}
|
|
13643
13643
|
};
|
|
@@ -17107,13 +17107,24 @@ function validateSchema(schema, data) {
|
|
|
17107
17107
|
}
|
|
17108
17108
|
|
|
17109
17109
|
// modules/realtime/logging/index.ts
|
|
17110
|
-
|
|
17110
|
+
var LOG_LEVELS = {
|
|
17111
|
+
debug: 0,
|
|
17112
|
+
info: 1,
|
|
17113
|
+
warn: 2,
|
|
17114
|
+
error: 3
|
|
17115
|
+
};
|
|
17116
|
+
function createWssLogger(namespace, socket, baseLogger, minLevel = "info") {
|
|
17111
17117
|
const context = {
|
|
17112
17118
|
namespace,
|
|
17113
17119
|
socketId: socket.id,
|
|
17114
17120
|
userId: socket.data?.user?.id || null
|
|
17115
17121
|
};
|
|
17122
|
+
const minLevelNum = LOG_LEVELS[minLevel] ?? LOG_LEVELS.info;
|
|
17116
17123
|
const log = (level, message, meta) => {
|
|
17124
|
+
const levelNum = LOG_LEVELS[level] ?? LOG_LEVELS.info;
|
|
17125
|
+
if (levelNum < minLevelNum) {
|
|
17126
|
+
return;
|
|
17127
|
+
}
|
|
17117
17128
|
const fullMeta = {
|
|
17118
17129
|
...context,
|
|
17119
17130
|
...meta,
|
|
@@ -17300,7 +17311,8 @@ async function setupWssEvents(options) {
|
|
|
17300
17311
|
namespace.on("connection", async (socket) => {
|
|
17301
17312
|
const requestId = generateRequestId();
|
|
17302
17313
|
socket.requestId = requestId;
|
|
17303
|
-
const
|
|
17314
|
+
const logLevel = realtimeConfig.logging?.level || (process.env.NODE_ENV === "production" ? "warn" : "info");
|
|
17315
|
+
const log = createWssLogger(namespacePath, socket, void 0, logLevel);
|
|
17304
17316
|
try {
|
|
17305
17317
|
const user = await executeAuth(normalized.auth, socket, namespacePath);
|
|
17306
17318
|
socket.data = socket.data || {};
|
|
@@ -17335,7 +17347,8 @@ async function setupWssEvents(options) {
|
|
|
17335
17347
|
socket.on(eventName, async (data) => {
|
|
17336
17348
|
const eventRequestId = generateRequestId();
|
|
17337
17349
|
socket.requestId = eventRequestId;
|
|
17338
|
-
const
|
|
17350
|
+
const eventLogLevel = realtimeConfig.logging?.level || (process.env.NODE_ENV === "production" ? "warn" : "info");
|
|
17351
|
+
const eventLog = createWssLogger(namespacePath, socket, void 0, eventLogLevel);
|
|
17339
17352
|
eventLog.debug(`Event received: ${eventName}`, { data });
|
|
17340
17353
|
try {
|
|
17341
17354
|
const ctx = {
|
|
@@ -17393,7 +17406,8 @@ async function setupWssEvents(options) {
|
|
|
17393
17406
|
await eventDef.handler(ctx);
|
|
17394
17407
|
eventLog.debug(`Event handled: ${eventName}`);
|
|
17395
17408
|
} catch (error) {
|
|
17396
|
-
const
|
|
17409
|
+
const errorLogLevel = realtimeConfig.logging?.level || (process.env.NODE_ENV === "production" ? "warn" : "info");
|
|
17410
|
+
const errorLog = createWssLogger(namespacePath, socket, void 0, errorLogLevel);
|
|
17397
17411
|
errorLog.error(`Error handling event ${eventName}`, {
|
|
17398
17412
|
error: error instanceof Error ? error.message : String(error),
|
|
17399
17413
|
stack: error instanceof Error ? error.stack : void 0
|
|
@@ -17413,9 +17427,10 @@ async function setupWssEvents(options) {
|
|
|
17413
17427
|
}
|
|
17414
17428
|
if (normalized.onDisconnect) {
|
|
17415
17429
|
try {
|
|
17430
|
+
const disconnectLogLevel = realtimeConfig.logging?.level || (process.env.NODE_ENV === "production" ? "warn" : "info");
|
|
17416
17431
|
const disconnectCtx = {
|
|
17417
17432
|
...baseCtx,
|
|
17418
|
-
log: createWssLogger(namespacePath, socket)
|
|
17433
|
+
log: createWssLogger(namespacePath, socket, void 0, disconnectLogLevel)
|
|
17419
17434
|
};
|
|
17420
17435
|
await normalized.onDisconnect(disconnectCtx, reason);
|
|
17421
17436
|
} catch (error) {
|