Skip to content

Commit

Permalink
Updated favicon setup and logger
Browse files Browse the repository at this point in the history
  • Loading branch information
roma2023 committed Sep 5, 2024
1 parent 6834c8b commit 0b3315b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 16 additions & 1 deletion src/webserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down

0 comments on commit 0b3315b

Please sign in to comment.