Start debug log

This commit is contained in:
Sacha Weatherstone
2022-02-14 11:34:29 +11:00
parent b98af7caca
commit 10be79267e
5 changed files with 32 additions and 6 deletions
+16 -1
View File
@@ -57,7 +57,7 @@ export const Connection = (): JSX.Element => {
}}
>
<Card>
<div className="w-full max-w-3xl p-10">
<div className="flex w-full max-w-3xl justify-between p-10">
{state.deviceStatus ===
Types.DeviceStatusEnum.DEVICE_DISCONNECTED ? (
<div className="space-y-2">
@@ -89,6 +89,21 @@ export const Connection = (): JSX.Element => {
)}
</div>
)}
<div className="rounded-md bg-secondaryDark p-2">
{state.logs.map((log, index) => (
<div className="flex">
<div>
[
{log.date.toLocaleTimeString(undefined, {
hour: '2-digit',
minute: '2-digit',
})}
]
</div>
<div key={index}>{log.message}</div>
</div>
))}
</div>
</div>
</Card>
</Modal>
+5
View File
@@ -2,6 +2,7 @@ import { connType } from '@core/slices/appSlice';
import {
addChannel,
addChat,
addLogEvent,
addMessage,
addNode,
addPosition,
@@ -86,6 +87,10 @@ export const cleanupListeners = (): void => {
const registerListeners = (): void => {
SettingsManager.debugMode = Protobuf.LogRecord_Level.TRACE;
connection.onLogEvent.subscribe((log) => {
store.dispatch(addLogEvent(log));
});
connection.onMeshPacket.subscribe((packet) => {
store.dispatch(
addRoute({
+6
View File
@@ -58,6 +58,7 @@ interface MeshtasticState {
hostOverrideEnabled: boolean;
hostOverride: string;
chats: ChatEntries;
logs: Types.LogEventPacket[];
}
const initialState: MeshtasticState = {
@@ -76,12 +77,16 @@ const initialState: MeshtasticState = {
localStorage.getItem('hostOverrideEnabled') === 'true' ?? false,
hostOverride: localStorage.getItem('hostOverride') ?? '',
chats: {},
logs: [],
};
export const meshtasticSlice = createSlice({
name: 'meshtastic',
initialState,
reducers: {
addLogEvent: (state, action: PayloadAction<Types.LogEventPacket>) => {
state.logs.push(action.payload);
},
setDeviceStatus: (state, action: PayloadAction<Types.DeviceStatusEnum>) => {
state.deviceStatus = action.payload;
},
@@ -276,6 +281,7 @@ export const meshtasticSlice = createSlice({
});
export const {
addLogEvent,
setDeviceStatus,
setLastMeshInterraction,
setReady,