feat: added new save logs to desktop

use instead of showing the debug window
pull/3145/head
yougotwill 8 months ago
parent 697896d52e
commit e22d044913

@ -4,6 +4,7 @@ const { Storage } = require('./ts/util/storage');
const { isTestNet, isTestIntegration } = require('./ts/shared/env_vars');
const os = require('os');
const url = require('url');
const _ = require('lodash');
@ -26,6 +27,9 @@ window.getAppInstance = () => configAny.appInstance;
window.getVersion = () => configAny.version;
window.getCommitHash = () => configAny.commitHash;
window.getNodeVersion = () => configAny.node_version;
window.getOSRelease = () =>
`${os.type()} ${os.release()}, Node.js ${config.node_version} ${os.platform()} ${os.arch()}`;
window.saveLog = logText => ipcRenderer.send('save-debug-log', logText);
window.sessionFeatureFlags = {
useOnionRequests: true,

@ -1,5 +1,3 @@
import { ipcRenderer } from 'electron';
import { useCallback } from 'react';
import { useSelector } from 'react-redux';
import styled from 'styled-components';
import { useMessageExpirationPropsById } from '../../../../hooks/useParamSelector';
@ -11,6 +9,7 @@ import { useSelectedIsGroupOrCommunity } from '../../../../state/selectors/selec
import { SpacerXS } from '../../../basic/Text';
import { SessionIcon, SessionIconType } from '../../../icon';
import { ExpireTimer } from '../../ExpireTimer';
import { saveLogToDesktop } from '../../../../util/logging';
type Props = {
messageId: string;
@ -228,9 +227,6 @@ const MessageStatusRead = ({
};
const MessageStatusError = ({ dataTestId }: Omit<Props, 'isDetailView'>) => {
const showDebugLog = useCallback(() => {
ipcRenderer.send('show-debug-log');
}, []);
// when on error, we do not display the expire timer at all.
const isGroup = useSelectedIsGroupOrCommunity();
@ -238,7 +234,9 @@ const MessageStatusError = ({ dataTestId }: Omit<Props, 'isDetailView'>) => {
<MessageStatusContainer
data-testid={dataTestId}
data-testtype="failed"
onClick={showDebugLog}
onClick={() => {
void saveLogToDesktop();
}}
title={window.i18n('sendFailed')}
isIncoming={false}
isGroup={isGroup}

@ -1,5 +1,4 @@
import { format, formatDistanceStrict } from 'date-fns';
import { ipcRenderer } from 'electron';
import { isEmpty } from 'lodash';
import moment from 'moment';
@ -24,6 +23,7 @@ import { useSelectedConversationKey } from '../../../../../../state/selectors/se
import { Flex } from '../../../../../basic/Flex';
import { SpacerSM } from '../../../../../basic/Text';
import { CopyToClipboardIcon } from '../../../../../buttons';
import { saveLogToDesktop } from '../../../../../../util/logging';
export const MessageInfoLabel = styled.label<{ color?: string }>`
font-size: var(--font-size-lg);
@ -74,10 +74,6 @@ export const LabelWithInfo = (props: LabelWithInfoProps) => {
// Message timestamp format: "06:02 PM Tue, 15/11/2022"
const formatTimestamps = 'hh:mm A ddd, D/M/Y';
const showDebugLog = () => {
ipcRenderer.send('show-debug-log');
};
const DebugMessageInfo = ({ messageId }: { messageId: string }) => {
const convoId = useSelectedConversationKey();
const messageHash = useMessageHash(messageId);
@ -164,7 +160,9 @@ export const MessageInfo = ({ messageId, errors }: { messageId: string; errors:
label={`${window.i18n('error')}:`}
info={errorString || window.i18n('unknownError')}
dataColor={'var(--danger-color)'}
onClick={showDebugLog}
onClick={() => {
void saveLogToDesktop();
}}
/>
</>
)}

@ -1,15 +1,14 @@
import { ipcRenderer } from 'electron';
import { SessionButtonShape, SessionButtonType } from '../../basic/SessionButton';
import { SessionSettingButtonItem, SessionSettingsTitleWithLink } from '../SessionSettingListItem';
import { saveLogToDesktop } from '../../../util/logging';
export const SettingsCategoryHelp = () => {
return (
<>
<SessionSettingButtonItem
onClick={() => {
ipcRenderer.send('show-debug-log');
void saveLogToDesktop();
}}
buttonShape={SessionButtonShape.Square}
buttonType={SessionButtonType.Solid}

@ -148,3 +148,11 @@ window.addEventListener('unhandledrejection', rejectionEvent => {
const errorInfo = error && error.stack ? error.stack : error;
window.log.error('Top-level unhandled promise rejection:', errorInfo);
});
export async function saveLogToDesktop() {
const operatingSystemInfo = `Operating System ${window.getOSRelease()}`;
const commitHashInfo = window.getCommitHash() ? `Commit ${window.getCommitHash()}` : '';
const text = await fetchNodeLog();
const debugLogWithSystemInfo = `${operatingSystemInfo} ${commitHashInfo} ${text}`;
window.saveLog(debugLogWithSystemInfo);
}

2
ts/window.d.ts vendored

@ -82,6 +82,7 @@ declare global {
getCommitHash: () => string | undefined;
getVersion: () => string;
getOSRelease: () => string;
saveLog: (text: string) => void;
setAutoHideMenuBar: (val: boolean) => void;
setMenuBarVisibility: (val: boolean) => void;
contextMenuShown: boolean;
@ -98,7 +99,6 @@ declare global {
getOpengroupPruning: () => Promise<boolean>;
setOpengroupPruning: (val: boolean) => Promise<void>;
closeAbout: () => void;
closeDebugLog: () => void;
getAutoUpdateEnabled: () => boolean;
setAutoUpdateEnabled: (enabled: boolean) => void;
setZoomFactor: (newZoom: number) => void;

Loading…
Cancel
Save