diff --git a/src/logger.js b/src/logger.js index 5c2b01426f..d252686ddb 100644 --- a/src/logger.js +++ b/src/logger.js @@ -98,12 +98,16 @@ Logger.open = function (value) { }; Logger.close = function (stream) { - if (stream.f !== process.stdout && stream.f) { - stream.end(); + // Check if stream.f is a valid stream and has the 'end' method + if (stream.f !== process.stdout && stream.f && typeof stream.f.end === 'function') { + stream.f.end(); // Close the stream + } else if (stream.f !== process.stdout) { + winston.warn('Logger stream is invalid or already closed.'); } stream.f = null; }; + Logger.monitorConfig = function (socket, data) { /* * This monitor's when a user clicks "save" in the Logger section of the admin panel diff --git a/src/webserver.js b/src/webserver.js index 4dea62224e..9b9f536cb8 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -218,13 +218,28 @@ function setupHelmet(app) { function setupFavicon(app) { + // Ensure 'brand:favicon' is available or use a default 'favicon.ico' let faviconPath = meta.config['brand:favicon'] || 'favicon.ico'; - faviconPath = path.join(nconf.get('base_dir'), 'public', faviconPath.replace(/assets\/uploads/, 'uploads')); + + // Ensure 'base_dir' is available, log an error if not + const baseDir = nconf.get('base_dir'); + if (!baseDir) { + winston.error('Base directory is not defined in configuration.'); + return; + } + + // Construct the full path for the favicon + faviconPath = path.join(baseDir, 'public', faviconPath.replace(/assets\/uploads/, 'uploads')); + + // Check if the favicon file exists before setting it up if (file.existsSync(faviconPath)) { app.use(nconf.get('relative_path'), favicon(faviconPath)); + } else { + winston.warn(`Favicon not found at ${faviconPath}, skipping favicon setup.`); } } + function configureBodyParser(app) { const urlencodedOpts = nconf.get('bodyParser:urlencoded') || {}; if (!urlencodedOpts.hasOwnProperty('extended')) {