Skip to content

Commit

Permalink
Fixed logging handler
Browse files Browse the repository at this point in the history
  • Loading branch information
NikkelM committed May 25, 2024
1 parent f149618 commit b6c97c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const configSyncDefaults = {
// 0 = only shorts, 1 = no option set (shorts are included), 2 = ignore shorts
"shuffleIgnoreShortsOption": 1,
"shuffleOpenAsPlaylistOption": true,
// How many random videos to add to a playlist
// How many random videos to add to a playlist (0-50)
"shuffleNumVideosInPlaylist": 10,
// If shuffled videos are opened in a new tab, save the tab ID of that tab here to reuse the tab when the user shuffles again
"shuffleTabId": null,
Expand Down
5 changes: 3 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
const oldLog = console.log;
console.log = function () {
// The last argument to console.log is a boolean that determines if the message should be shown in production
const showInProduction = arguments[arguments.length - 1] === true;
const showInProduction = (arguments.length > 1 && arguments[arguments.length - 1] === true);
// If we are either in development or the message should be shown in production, log the message
if (process.env.NODE_ENV !== 'production' || showInProduction) {
if (arguments[0] !== "[random-youtube-video]:") {
Array.prototype.unshift.call(arguments, '[random-youtube-video]:');
}
// Remove the showInProduction flag from the arguments so it doesn't get logged
if (typeof arguments[arguments.length - 1] === 'boolean') {
// Only remove the last argument if there are more than 2 arguments (prefix, normal argument, showInProduction flag)
if (arguments.length > 2 && typeof arguments[arguments.length - 1] === 'boolean') {
Array.prototype.pop.call(arguments);
}
oldLog.apply(this, arguments);
Expand Down

0 comments on commit b6c97c2

Please sign in to comment.