setup piping ml console logs to debugLogs
This commit is contained in:
parent
49d76f10ae
commit
3204ec50c9
|
@ -19,7 +19,7 @@ import {
|
|||
getMLSearchConfig,
|
||||
updateMLSearchConfig,
|
||||
} from 'utils/machineLearning/config';
|
||||
import { addLogLine } from 'utils/logging';
|
||||
import { addLogLine, pipeConsoleLogsToDebugLogs } from 'utils/logging';
|
||||
import LoadingBar from 'react-top-loading-bar';
|
||||
import DialogBox from 'components/DialogBox';
|
||||
import { styled, ThemeProvider } from '@mui/material/styles';
|
||||
|
@ -105,12 +105,9 @@ export default function App({ Component, err }) {
|
|||
process.env.NODE_ENV !== 'production'
|
||||
) {
|
||||
console.warn('Progressive Web App support is disabled');
|
||||
return;
|
||||
}
|
||||
// const wb = new Workbox('sw.js', { scope: '/' });
|
||||
// wb.register();
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
} else if ('serviceWorker' in navigator) {
|
||||
// const wb = new Workbox('sw.js', { scope: '/' });
|
||||
// wb.register();
|
||||
navigator.serviceWorker.onmessage = (event) => {
|
||||
if (event.data.action === 'upload-files') {
|
||||
const files = event.data.files;
|
||||
|
@ -133,6 +130,7 @@ export default function App({ Component, err }) {
|
|||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
pipeConsoleLogsToDebugLogs();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -3,6 +3,14 @@ import { convertBytesToHumanReadable } from 'utils/file/size';
|
|||
import { formatDateTime } from 'utils/time';
|
||||
import { saveLogLine, getLogs } from 'utils/storage';
|
||||
|
||||
export function pipeConsoleLogsToDebugLogs() {
|
||||
const oldLog = console.log;
|
||||
console.log = function (...args) {
|
||||
addLogLine(args.map((x) => JSON.stringify(x)).join(' '));
|
||||
oldLog.apply(console, args);
|
||||
};
|
||||
}
|
||||
|
||||
export function addLogLine(log: string) {
|
||||
saveLogLine({
|
||||
timestamp: Date.now(),
|
||||
|
|
|
@ -5,7 +5,7 @@ export interface Log {
|
|||
logLine: string;
|
||||
}
|
||||
|
||||
const MAX_LOG_LINES = 1000;
|
||||
const MAX_LOG_LINES = 10000;
|
||||
|
||||
export const isFirstLogin = () =>
|
||||
getData(LS_KEYS.IS_FIRST_LOGIN)?.status ?? false;
|
||||
|
|
Loading…
Reference in a new issue