domma-cms 0.52.0 → 0.53.0

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server/server.js +24 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domma-cms",
3
- "version": "0.52.0",
3
+ "version": "0.53.0",
4
4
  "description": "File-based CMS powered by Domma and Fastify. Run npx domma-cms my-site to create a new project.",
5
5
  "type": "module",
6
6
  "main": "server/server.js",
package/server/server.js CHANGED
@@ -56,8 +56,31 @@ if (MANAGER_SECRET && MANAGER_SECRET.length < 32) {
56
56
  console.warn(' WARNING: MANAGER_SECRET is set but too short (minimum 32 characters). Manager notifications disabled until fixed.');
57
57
  }
58
58
 
59
+ /**
60
+ * Resolve the log level.
61
+ *
62
+ * `config/server.json` → `logging.level` wins; otherwise info in development
63
+ * and warn in production, as before. Made configurable because `warn` hides
64
+ * every 4xx and every `log.info` a plugin writes, so a rejected admin action -
65
+ * a site that fails to create, a certificate that fails to issue - leaves no
66
+ * trace at all and cannot be diagnosed after the fact.
67
+ *
68
+ * An unrecognised value falls back rather than throwing: a typo here must not
69
+ * stop the server booting.
70
+ */
71
+ function resolveLogLevel() {
72
+ const VALID = ['fatal', 'error', 'warn', 'info', 'debug', 'trace', 'silent'];
73
+ const fallback = process.env.NODE_ENV === 'development' ? 'info' : 'warn';
74
+ const requested = process.env.LOG_LEVEL || (config.server && config.server.logging && config.server.logging.level);
75
+ if (!requested) return fallback;
76
+ const level = String(requested).toLowerCase().trim();
77
+ if (VALID.includes(level)) return level;
78
+ console.warn(` WARNING: unknown log level "${requested}" - falling back to "${fallback}". Valid: ${VALID.join(', ')}`);
79
+ return fallback;
80
+ }
81
+
59
82
  const app = Fastify({
60
- logger: {level: process.env.NODE_ENV === 'development' ? 'info' : 'warn'},
83
+ logger: {level: resolveLogLevel()},
61
84
  // When running behind a reverse proxy (e.g. domma-cms-manager), trust the
62
85
  // X-Forwarded-For header so @fastify/rate-limit keys on the real client IP
63
86
  // rather than the proxy's loopback address.