CH-J Server ManagerZarządzanie serwerem przez SSH
Menu
Opublikowane źródło

CH-J Server Manager

Przeglądaj katalogi i pliki dla konkretnego wydania aplikacji.

Pobierz źródło ZIP
CH-J / Server Manager 339 pliki
core-20261014T184258Z-3fbed0b93fdf Dodano: Data niezanotowana · Built:
Pliki
logger.js Dodano: Data niezanotowana 1,5 KB · 44 linie
Pobierz plik PDF
1"use strict";
3const fs = require("node:fs");
4const path = require("node:path");
6const SENSITIVE_KEYS = /pass(word|phrase)?|private.?key|secret|token|credential/i;
8function sanitize(value, depth = 0) {
9 if (depth > 5) return "[depth-limit]";
10 if (Array.isArray(value)) return value.slice(0, 50).map((item) => sanitize(item, depth + 1));
11 if (!value || typeof value !== "object") return value;
12 const result = {};
13 for (const [key, entry] of Object.entries(value)) {
14 result[key] = SENSITIVE_KEYS.test(key) ? "[redacted]" : sanitize(entry, depth + 1);
15 }
16 return result;
19class Logger {
20 constructor(rootDir) {
21 this.logDir = path.join(rootDir, "logs");
22 this.logPath = path.join(this.logDir, "core.log");
23 fs.mkdirSync(this.logDir, { recursive: true });
24 }
26 write(level, message, data = {}) {
27 const record = {
28 timestamp: new Date().toISOString(),
29 level,
30 message: String(message || ""),
31 data: sanitize(data)
32 };
33 const line = `${JSON.stringify(record)}\n`;
34 try { fs.appendFileSync(this.logPath, line, { encoding: "utf8", mode: 0o600 }); } catch {}
35 const output = level === "error" ? console.error : level === "warn" ? console.warn : console.log;
36 output(`[${level.toUpperCase()}] ${record.message}`, record.data);
37 }
39 info(message, data) { this.write("info", message, data); }
40 warn(message, data) { this.write("warn", message, data); }
41 error(message, data) { this.write("error", message, data); }
44module.exports = { Logger, sanitize };
SHA-25689d04a484d9f684bf017a708c287c87d3f4fda912207ba8f7dc06bd33b35e5c5

CH-J Proprietary Software License 1.14 · Źródło jest dostarczane pod CH-J Proprietary Software License 1.14. Jego dostępność nie zmienia warunków licencji ani nie przyznaje dodatkowych praw.

SHA-2563df08cf5e899262a6ce92d7ec2caf5c42b683f1f2b57055662b845ff7dde67a8