From ab6bccade6c5767e9bbbb43aa2a1a1bf5a7fa927 Mon Sep 17 00:00:00 2001 From: Warrick Corfe-Tan Date: Wed, 6 Oct 2021 11:35:57 +1100 Subject: [PATCH 1/5] Added additional information to debug logs. --- _locales/en/messages.json | 4 +++- debug_log_preload.js | 4 ++++ js/views/debug_log_view.js | 7 ++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 8b649412b..148d68311 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -443,5 +443,7 @@ "messageDeletedPlaceholder": "This message has been deleted", "messageDeleted": "Message deleted", "surveyTitle": "Take our Session Survey", - "goToOurSurvey": "Go to our survey" + "goToOurSurvey": "Go to our survey", + "operatingSystem": "Operating System: $operatingSystem$\n", + "commitHash": "Git Commit SHA: $commitHash$\n" } diff --git a/debug_log_preload.js b/debug_log_preload.js index 8121af5d6..dbd23deff 100644 --- a/debug_log_preload.js +++ b/debug_log_preload.js @@ -22,5 +22,9 @@ window.getNodeVersion = () => config.node_version; window.getEnvironment = () => config.environment; require('./js/logging'); +const os = require('os'); + +window.getOSRelease = () => `${os.type()} ${os.release} ${os.platform()}`; +window.getCommitHash = () => config.commitHash; window.closeDebugLog = () => ipcRenderer.send('close-debug-log'); diff --git a/js/views/debug_log_view.js b/js/views/debug_log_view.js index 1ed681538..17bda295a 100644 --- a/js/views/debug_log_view.js +++ b/js/views/debug_log_view.js @@ -26,9 +26,14 @@ this.render(); this.$('textarea').val(i18n('loading')); + const operatingSystemInfo = `${i18n('operatingSystem', window.getOSRelease())}`; + const commitHashInfo = i18n('commitHash', window.getCommitHash()); + // eslint-disable-next-line more/no-then window.log.fetch().then(text => { - this.$('textarea').val(text); + const debugLogWithSystemInfo = operatingSystemInfo + commitHashInfo + text; + + this.$('textarea').val(debugLogWithSystemInfo); }); }, events: { From 1fe6b61308ea48f0614b0adc088cd88e89bae1dd Mon Sep 17 00:00:00 2001 From: Warrick Corfe-Tan Date: Mon, 11 Oct 2021 12:25:27 +1100 Subject: [PATCH 2/5] Re-adding code that wasn't commited. Adding button for debug log in settings. --- _locales/en/messages.json | 1 + .../message/OutgoingMessageStatus.tsx | 7 ++++++- .../session/settings/SessionSettings.tsx | 19 ++++++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 148d68311..652bb95f4 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -73,6 +73,7 @@ "attemptingReconnection": "Attempting reconnect in $reconnect_duration_in_seconds$ seconds", "submitDebugLog": "Debug log", "debugLog": "Debug Log", + "showDebugLog": "Show Debug Log", "goToReleaseNotes": "Go to Release Notes", "goToSupportPage": "Go to Support Page", "menuReportIssue": "Report an Issue", diff --git a/ts/components/conversation/message/OutgoingMessageStatus.tsx b/ts/components/conversation/message/OutgoingMessageStatus.tsx index 2a6869b75..a386fdd95 100644 --- a/ts/components/conversation/message/OutgoingMessageStatus.tsx +++ b/ts/components/conversation/message/OutgoingMessageStatus.tsx @@ -1,3 +1,4 @@ +import { ipcRenderer } from 'electron/renderer'; import React from 'react'; import styled from 'styled-components'; import { MessageDeliveryStatus } from '../../../models/messageType'; @@ -40,8 +41,12 @@ const MessageStatusRead = () => { }; const MessageStatusError = () => { + const showDebugLog = () => { + ipcRenderer.send('show-debug-log'); + }; + return ( - + ); diff --git a/ts/components/session/settings/SessionSettings.tsx b/ts/components/session/settings/SessionSettings.tsx index 05db39c86..487bc236b 100644 --- a/ts/components/session/settings/SessionSettings.tsx +++ b/ts/components/session/settings/SessionSettings.tsx @@ -14,7 +14,7 @@ import { getPasswordHash, hasLinkPreviewPopupBeenDisplayed, } from '../../../../ts/data/data'; -import { shell } from 'electron'; +import { ipcRenderer, shell } from 'electron'; import { mapDispatchToProps } from '../../../state/actions'; import { unblockConvoById } from '../../../interactions/conversationInteractions'; import { toggleAudioAutoplay } from '../../../state/ducks/userConfig'; @@ -497,6 +497,23 @@ class SettingsViewInner extends React.Component { buttonColor: SessionButtonColor.Primary, }, }, + { + id: 'debug-log-setting', + title: window.i18n('showDebugLog'), + description: undefined, + hidden: false, + type: SessionSettingType.Button, + category: SessionSettingCategory.Appearance, + setFn: undefined, + comparisonValue: undefined, + onClick: () => { + ipcRenderer.send('show-debug-log'); + }, + content: { + buttonText: window.i18n('debugLog'), + buttonColor: SessionButtonColor.Primary, + }, + }, { id: 'media-permissions', title: window.i18n('mediaPermissionsTitle'), From 3c4dc7f0388df1d3aabf52b51fbd4aeb78f67e50 Mon Sep 17 00:00:00 2001 From: Warrick Corfe-Tan Date: Mon, 11 Oct 2021 12:28:34 +1100 Subject: [PATCH 3/5] Making commit hash show conditionally. --- js/views/debug_log_view.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/views/debug_log_view.js b/js/views/debug_log_view.js index 17bda295a..cb1d9e597 100644 --- a/js/views/debug_log_view.js +++ b/js/views/debug_log_view.js @@ -27,7 +27,10 @@ this.$('textarea').val(i18n('loading')); const operatingSystemInfo = `${i18n('operatingSystem', window.getOSRelease())}`; - const commitHashInfo = i18n('commitHash', window.getCommitHash()); + + const commitHashInfo = window.getCommitHash() + ? i18n('commitHash', window.getCommitHash()) + : ''; // eslint-disable-next-line more/no-then window.log.fetch().then(text => { From 04e0023d382e913ad1c5d823fba12024be955e24 Mon Sep 17 00:00:00 2001 From: Warrick Corfe-Tan Date: Mon, 11 Oct 2021 12:35:14 +1100 Subject: [PATCH 4/5] fix import warning --- ts/components/conversation/message/OutgoingMessageStatus.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts/components/conversation/message/OutgoingMessageStatus.tsx b/ts/components/conversation/message/OutgoingMessageStatus.tsx index a386fdd95..0701ce131 100644 --- a/ts/components/conversation/message/OutgoingMessageStatus.tsx +++ b/ts/components/conversation/message/OutgoingMessageStatus.tsx @@ -1,4 +1,4 @@ -import { ipcRenderer } from 'electron/renderer'; +import { ipcRenderer } from 'electron'; import React from 'react'; import styled from 'styled-components'; import { MessageDeliveryStatus } from '../../../models/messageType'; From 2b28ec93f993280ac953a6ca47fc05373f81727b Mon Sep 17 00:00:00 2001 From: Warrick Corfe-Tan Date: Mon, 11 Oct 2021 14:20:33 +1100 Subject: [PATCH 5/5] removed translation for debug logs. --- _locales/en/messages.json | 4 +--- js/views/debug_log_view.js | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 652bb95f4..f9168cc88 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -444,7 +444,5 @@ "messageDeletedPlaceholder": "This message has been deleted", "messageDeleted": "Message deleted", "surveyTitle": "Take our Session Survey", - "goToOurSurvey": "Go to our survey", - "operatingSystem": "Operating System: $operatingSystem$\n", - "commitHash": "Git Commit SHA: $commitHash$\n" + "goToOurSurvey": "Go to our survey" } diff --git a/js/views/debug_log_view.js b/js/views/debug_log_view.js index cb1d9e597..4ef324362 100644 --- a/js/views/debug_log_view.js +++ b/js/views/debug_log_view.js @@ -26,11 +26,9 @@ this.render(); this.$('textarea').val(i18n('loading')); - const operatingSystemInfo = `${i18n('operatingSystem', window.getOSRelease())}`; + const operatingSystemInfo = `Operating System: ${window.getOSRelease()}`; - const commitHashInfo = window.getCommitHash() - ? i18n('commitHash', window.getCommitHash()) - : ''; + const commitHashInfo = window.getCommitHash() ? `Commit Hash: ${window.getCommitHash()}` : ''; // eslint-disable-next-line more/no-then window.log.fetch().then(text => {