From 94770cf865959112499337a287d11473e1e65595 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Tue, 12 Apr 2022 16:57:22 +0800 Subject: [PATCH] Resolve log message null reference --- server/routers/api-router.js | 2 +- server/server.js | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/server/routers/api-router.js b/server/routers/api-router.js index 4813fb550..b7645a837 100644 --- a/server/routers/api-router.js +++ b/server/routers/api-router.js @@ -124,7 +124,7 @@ router.get("/api/status-page/:slug", cache("5 minutes"), async (request, respons // Public Group List const publicGroupList = []; const showTags = !!statusPage.show_tags; - debug("Show Tags???" + showTags); + const list = await R.find("group", " public = 1 AND status_page_id = ? ORDER BY weight ", [ statusPage.id ]); diff --git a/server/server.js b/server/server.js index 94d0ce729..faad4a581 100644 --- a/server/server.js +++ b/server/server.js @@ -11,7 +11,7 @@ if (nodeVersion < requiredVersion) { } const args = require("args-parser")(process.argv); -const { sleep, log_info, log_debug, log_error, log_warn, getRandomInt, genSecret } = require("../src/util"); +const { sleep, log_info, log_debug, log_error, log_warn, getRandomInt, genSecret, debug } = require("../src/util"); const config = require("./config"); log_info("server", "Welcome to Uptime Kuma"); @@ -84,7 +84,7 @@ Notification.init(); log_debug("server", "Importing Proxy"); const { Proxy } = require("./proxy"); -debug("Importing Database"); +log_debug("server", "Importing Database"); const Database = require("./database"); log_debug("server", "Importing Background Jobs"); @@ -326,7 +326,7 @@ try { } } catch (error) { - log_error("auth", `Invalid token for user ${decoded.username}. IP=${getClientIp(socket)}`); + log_error("auth", `Invalid token. IP=${getClientIp(socket)}`); callback({ ok: false, @@ -494,7 +494,7 @@ try { socket.userID, ]); - log_info("auth", `Saved 2FA token for user ${data.username}. IP=${getClientIp(socket)}`); + log_info("auth", `Saved 2FA token. IP=${getClientIp(socket)}`); callback({ ok: true, @@ -502,7 +502,7 @@ try { }); } catch (error) { - log_error("auth", `Error changing 2FA token for user ${data.username}. IP=${getClientIp(socket)}`); + log_error("auth", `Error changing 2FA token. IP=${getClientIp(socket)}`); callback({ ok: false, @@ -521,7 +521,7 @@ try { await doubleCheckPassword(socket, currentPassword); await TwoFA.disable2FA(socket.userID); - log_info("auth", `Disabled 2FA token for user ${data.username}. IP=${getClientIp(socket)}`); + log_info("auth", `Disabled 2FA token. IP=${getClientIp(socket)}`); callback({ ok: true, @@ -529,7 +529,7 @@ try { }); } catch (error) { - log_error("auth", `Error disabling 2FA token for user ${data.username}. IP=${getClientIp(socket)}`); + log_error("auth", `Error disabling 2FA token. IP=${getClientIp(socket)}`); callback({ ok: false, @@ -657,7 +657,7 @@ try { await server.sendMonitorList(socket); await startMonitor(socket.userID, bean.id); - log_info("monitor", `Added Monitor: ${monitorID} User ID: ${socket.userID}`); + log_info("monitor", `Added Monitor: ${monitor.id} User ID: ${socket.userID}`); callback({ ok: true, @@ -667,7 +667,7 @@ try { } catch (e) { - log_error("monitor", `Error adding Monitor: ${monitorID} User ID: ${socket.userID}`); + log_error("monitor", `Error adding Monitor: ${monitor.id} User ID: ${socket.userID}`); callback({ ok: false, @@ -1672,7 +1672,7 @@ async function shutdownFunction(signal) { } function getClientIp(socket) { - return socket.client.conn.remoteAddress.replace(/^.*:/, "") + return socket.client.conn.remoteAddress.replace(/^.*:/, ""); } function finalFunction() {