Skip to content

Commit

Permalink
feat(electron,logging) log all console logs to a file
Browse files Browse the repository at this point in the history
  • Loading branch information
dudumanbogdan authored Dec 6, 2022
1 parent f59395b commit ad341fe
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 92 deletions.
23 changes: 9 additions & 14 deletions spot-client/src/common/logger/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,30 @@ const jitsiLogger = getLogger(null, null, { disableCallerInfo: true });
* @returns {string} The log object, which includes metadata, as a string.
*/
function formatMessage(level, message, context) {
const formattedMessage = {
level,
timestamp: Date.now(),
message
};
let contextValue;

if (context) {
if (typeof context === 'string') {
formattedMessage.context = context;
contextValue = context;
} else {
const contextCopy = { ...context };

for (const key in contextCopy) {
if (contextCopy.hasOwnProperty(key)
&& contextCopy[key] instanceof Error) {
if (contextCopy.hasOwnProperty(key) && contextCopy[key] instanceof Error) {
const error = contextCopy[key];

contextCopy[key] = JSON.stringify(
error,
Object.getOwnPropertyNames(error)
);
contextCopy[key] = JSON.stringify(error, Object.getOwnPropertyNames(error));
}
}
formattedMessage.context = contextCopy;
contextValue = JSON.stringify(contextCopy);
}
}

if (contextValue) {
return `${message} ${contextValue}`;
}

return formattedMessage;
return message;
}

/**
Expand Down
140 changes: 114 additions & 26 deletions spot-electron/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ad341fe

Please sign in to comment.