Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
3325608
Added config file on backend
Jopat2409 Aug 22, 2025
dfbd218
Changed print to log
Jopat2409 Aug 22, 2025
8797748
Added logging stream handler and socket handler
Jopat2409 Aug 22, 2025
443a5d9
Run log setup on create app
Jopat2409 Aug 22, 2025
5ba4638
Added two log handlers
Jopat2409 Aug 22, 2025
22d7bb2
Create log handlers on socket init
Jopat2409 Aug 22, 2025
f2df11d
Register logging redux slice
Jopat2409 Aug 22, 2025
bfb1a56
Dispatch log event on reception from backend
Jopat2409 Aug 22, 2025
928c94d
Add log history
Jopat2409 Aug 22, 2025
0894783
Ensure logging is initialised after sockio connection
Jopat2409 Aug 22, 2025
214e91f
Add log4js
Jopat2409 Aug 22, 2025
087db9d
Add logging settings
Jopat2409 Aug 22, 2025
0b5b3be
Extract electron functionality into modules
Jopat2409 Aug 22, 2025
f7dc2bb
Add exposed ipcRenderer methods
Jopat2409 Aug 22, 2025
a992f81
Add electron log handler
Jopat2409 Aug 22, 2025
9b62381
Add directory setting type
Jopat2409 Aug 22, 2025
55e7c06
Remove buggy import
Jopat2409 Aug 22, 2025
2459fe6
Remove annoying log
Jopat2409 Aug 22, 2025
68e2294
Update console log to logging
Jopat2409 Aug 22, 2025
e40d706
Removed console logger from backend (since it will be logged through …
Jopat2409 Aug 23, 2025
a57680e
Merge branch 'release-alpha-0.1.10' of https://github.com/Avis-Drone-…
Jopat2409 Aug 23, 2025
0fb1936
Added logging
Jopat2409 Aug 23, 2025
4926897
Merge branch 'release-alpha-0.1.10' of https://github.com/Avis-Drone-…
Jopat2409 Aug 23, 2025
59e0aeb
Removed logging from slice reducers. Logging should be done where the…
Jopat2409 Aug 23, 2025
845d26c
Added multiFile
Jopat2409 Aug 23, 2025
643f1b5
Added log4js to external options
Jopat2409 Aug 23, 2025
6bfb066
Add distinction between backend and frontend logs
Jopat2409 Aug 23, 2025
6a58839
Logs are now sent to gcs/logs when in development mode
Jopat2409 Aug 23, 2025
63cbfe7
Fixed bug with bad settings read
Jopat2409 Aug 23, 2025
c3832a9
Updated logging methods
Jopat2409 Aug 23, 2025
94857ac
Updated logging
Jopat2409 Aug 23, 2025
4ec88b5
Added logging methods
Jopat2409 Aug 23, 2025
98e9341
Updated logging messages
Jopat2409 Aug 23, 2025
bca2e7c
Updated logging messages
Jopat2409 Aug 23, 2025
41083a3
Update logging
Jopat2409 Aug 24, 2025
7a0a2a6
Merge branch 'release-alpha-0.1.10' of https://github.com/Avis-Drone-…
Jopat2409 Aug 25, 2025
837647e
Remove debug log count
Jopat2409 Aug 25, 2025
9b881ad
Merge branch 'release-alpha-0.1.10' of https://github.com/Avis-Drone-…
Jopat2409 Aug 25, 2025
8f468f3
Logging now follows development settings
Jopat2409 Aug 25, 2025
61b590e
Created log helpers for electron logging
Jopat2409 Aug 25, 2025
bc3ea4b
Ignore annoying typescript issue
Jopat2409 Aug 25, 2025
a26684f
Remove caller from log format if logging to separate files
Jopat2409 Aug 25, 2025
53eb7f2
Add socket emit hook
Jopat2409 Aug 25, 2025
a4878e8
Stop typescript crying at me
Jopat2409 Aug 25, 2025
3851c80
Finished up logging
Jopat2409 Aug 25, 2025
6724699
Add a bit of documentation
Jopat2409 Aug 26, 2025
289d8f3
Update default log format
Jopat2409 Aug 26, 2025
3be5a9c
Removed unused electron logger
Jopat2409 Aug 26, 2025
5e3013c
Moved log dispatch to middleware because reducers are supposed to be …
Jopat2409 Aug 26, 2025
cbe4108
Fixed combining files being the wrong way round
Jopat2409 Aug 26, 2025
4e9f866
Bad descriptor gone
Jopat2409 Aug 26, 2025
27fed4b
Explicitly import process to please eslint
Jopat2409 Aug 26, 2025
7b8d0a3
Fix ruff issues
Jopat2409 Aug 26, 2025
fdaf361
More ruff fixes + ran linter
Jopat2409 Aug 26, 2025
1f52562
Fixed bad tests and ruff issues
Jopat2409 Aug 26, 2025
75f51c8
Fix spelling mistake thanks copilot
Jopat2409 Aug 26, 2025
9b0fe6d
Stupid suggestion but I love copilot so sure
Jopat2409 Aug 26, 2025
bf1002e
I can't soekk received
Jopat2409 Aug 26, 2025
3a978cb
Update gcs/src/components/settingsModal.jsx
Jopat2409 Aug 26, 2025
07c4c24
Fix mypy issue and fix copilot slop suggestions
Jopat2409 Aug 26, 2025
adc491f
Merge branch 'alpha-0.1.10/553-add-logging-on-frontend-and-backend' o…
Jopat2409 Aug 26, 2025
b093977
Fix missing prettier files for some reason
Jopat2409 Aug 26, 2025
80594f8
Holy yarn format
Jopat2409 Aug 26, 2025
5ea8f20
Merge branch 'release-alpha-0.1.10' into alpha-0.1.10/553-add-logging…
1Blademaster Sep 4, 2025
0daa88b
Merge branch 'release-alpha-0.1.10' of https://github.com/Avis-Drone-…
Jopat2409 Sep 8, 2025
92718c3
Complete merge
Jopat2409 Sep 8, 2025
ff1ae0a
Fix issue with store
Jopat2409 Sep 8, 2025
e80c3b6
Fixed attempting to access NODE_ENV on frontend
Jopat2409 Sep 14, 2025
42ca02a
Removed log incoming messages
Jopat2409 Sep 14, 2025
57fe792
Update radio/app/controllers/gripperController.py
Jopat2409 Sep 14, 2025
4c889ed
Update radio/app/controllers/gripperController.py
Jopat2409 Sep 14, 2025
5a0f89b
Update radio/app/controllers/armController.py
Jopat2409 Sep 14, 2025
32d336c
Update radio/app/controllers/gripperController.py
Jopat2409 Sep 14, 2025
ce2cdcc
Update radio/app/controllers/frameController.py
Jopat2409 Sep 14, 2025
c64a2ba
Add console logger for pytest
Jopat2409 Sep 14, 2025
a9e9d49
Merge branch 'alpha-0.1.10/553-add-logging-on-frontend-and-backend' o…
Jopat2409 Sep 14, 2025
a507e41
Remove unneeded log
Jopat2409 Sep 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gcs/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ build
coverage
dist
dist-electron
data
data
6 changes: 6 additions & 0 deletions gcs/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": false,
"singleQuote": false,
"jsxSingleQuote": false,
"trailingComma": "all"
}
29 changes: 28 additions & 1 deletion gcs/data/default_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,32 @@
},
"Params": {},
"Config": {},
"FGCS": {}
"FGCS": {},
"Development": {
"logToWorkingDirectory": {
"description": "Log files will be placed in gcs/logs instead of appdata/FGCS/logs",
"display": "Log to Development Workspace",
"type": "boolean",
"default": false
},
Comment on lines +64 to +69
Copy link
Copy Markdown
Member

@1Blademaster 1Blademaster Sep 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of making this a setting, can we check if it's a development environment and log to gcs/logs, if it's prod then use default log location?

"loggingFormat": {
"description": "Format for log messages. See log4js patterns for more info",
"display": "Log Format",
"type": "string",
"default": "[%d{dd/MM/yyyy hh:mm:ss:SSS}] [%p] %c - %m"
},
"loggingLevel": {
"description": "Current development log level",
"display": "Log Level",
"type": "option",
"options": ["DEBUG", "INFO", "WARNING", "ERROR", "FATAL"],
"default": "INFO"
},
"combineLogs": {
"description": "Combine frontend and backend logs into a single file",
"display": "Combine Log Files",
"type": "boolean",
"default": false
}
}
}
167 changes: 49 additions & 118 deletions gcs/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@ import path from "node:path"
import packageInfo from "../package.json"

// @ts-expect-error - no types available
import openFile, { clearRecentFiles, getRecentFiles } from "./fla"
import registerAboutIPC, {
destroyAboutWindow,
openAboutPopout,
} from "./modules/aboutWindow"
import registerLinkStatsIPC, {
destroyLinkStatsWindow,
} from "./modules/linkStatsWindow"
import registerWebcamIPC, { destroyWebcamWindow } from "./modules/webcam"
import openFile, { clearRecentFiles, getRecentFiles } from './fla'
import registerSettingsIPC, { getSetting } from './modules/settings'
import registerWebcamIPC, { destroyWebcamWindow } from './modules/webcam'
import registerLoggingIPC, { setupLog4js, logFatal, logWarning, logInfo } from './modules/logging'
import registerAboutIPC, { destroyAboutWindow, openAboutPopout } from "./modules/aboutWindow"
import registerLinkStatsIPC, { destroyLinkStatsWindow } from "./modules/linkStatsWindow"
// The built directory structure
//
// ├─┬─┬ dist
Expand Down Expand Up @@ -64,91 +61,13 @@ function getWindow() {
return BrowserWindow.getFocusedWindow()
}

// Settings logic
registerLoggingIPC();
registerSettingsIPC();

interface Settings {
version: string
settings: object
}

let userSettings: Settings | null = null

function saveUserConfiguration(settings: Settings) {
userSettings = settings
fs.writeFileSync(
path.join(app.getPath("userData"), "settings.json"),
JSON.stringify(userSettings, null, 2),
"utf-8",
)
}

/**
* Checks the application version within the loaded user settings and updates if it is outdated
* @param configPath The path to the configuration file
* @returns
*/
function checkAppVersion(configPath: string) {
if (userSettings === null) {
console.warn(
"Attempting to check app version when user settings have not been loaded",
)
return
}

if (userSettings.version == app.getVersion()) return

userSettings.version = app.getVersion()
fs.writeFileSync(configPath, JSON.stringify(userSettings))
}

/**
* Called when the application requests user settings
*
* @returns
*/
function getUserConfiguration() {
// Return the already loaded user settings if loaded
console.log("Fetching user settings!")
if (userSettings !== null) return userSettings

// Directories
const userDir = app.getPath("userData")
const config = path.join(userDir, "settings.json")

// Write version and blank settings to user config if doesn't exist
if (!fs.existsSync(config)) {
console.log("Generating user settings")
userSettings = { version: app.getVersion(), settings: {} }
fs.writeFileSync(config, JSON.stringify(userSettings))
} else {
console.log("Reading user settings from config file " + config)
userSettings = JSON.parse(fs.readFileSync(config, "utf-8"))
checkAppVersion(config)
}
return userSettings
}

ipcMain.handle("getSettings", () => {
return getUserConfiguration()
})
ipcMain.handle("setSettings", (_, settings) => {
saveUserConfiguration(settings)
})

ipcMain.handle("isMac", () => {
return process.platform == "darwin"
})
ipcMain.on("close", () => {
closeWithBackend()
})
ipcMain.on("minimise", () => {
getWindow()?.minimize()
})
ipcMain.on("maximise", () => {
getWindow()?.isMaximized()
? getWindow()?.unmaximize()
: getWindow()?.maximize()
})
ipcMain.handle("isMac", () => { return process.platform == "darwin" })
ipcMain.on('close', () => {closeWithBackend()})
ipcMain.on('minimise', () => {getWindow()?.minimize()})
ipcMain.on('maximise', () => {getWindow()?.isMaximized() ? getWindow()?.unmaximize() : getWindow()?.maximize()})

ipcMain.on("reload", () => {
getWindow()?.reload()
Expand Down Expand Up @@ -179,6 +98,15 @@ ipcMain.on("openFileInExplorer", (_event, filePath) => {
shell.showItemInFolder(filePath)
})

ipcMain.handle('selectDirectory', async () => {
const result = await dialog.showOpenDialog({
properties: ['openDirectory'],
defaultPath: app.getAppPath()
});
if (result.canceled) return null;
return result.filePaths[0];
});

function createWindow() {
win = new BrowserWindow({
icon: path.join(process.env.VITE_PUBLIC, "app_icon.ico"),
Expand Down Expand Up @@ -291,11 +219,11 @@ function createLoadingWindow() {

function startBackend() {
if (pythonBackend) {
console.log("Backend already running")
return
logWarning('Backend already running');
return;
}

console.log("Starting backend")
logInfo('Starting backend');

// Add more platforms here
const backendPaths: Partial<Record<NodeJS.Platform, string>> = {
Expand All @@ -313,28 +241,25 @@ function startBackend() {
const backendPath = backendPaths[process.platform]

if (!backendPath) {
console.error("Unsupported platform!")
return
logFatal('Unsupported platform!');
return;
}

console.log(`Starting backend: ${backendPath}`)
pythonBackend = spawn(backendPath)
logInfo(`Starting backend: ${backendPath}`);
pythonBackend = spawn(backendPath);

// pythonBackend.stdout.on('data', (data) => console.log(`Backend stdout: ${data}`));
// pythonBackend.stderr.on('data', (data) => console.error(`Backend stderr: ${data}`));

pythonBackend.on("close", (code) => {
console.log(`Backend process exited with code ${code}`)
pythonBackend = null
})
pythonBackend.on('close', (code) => {
logInfo(`Backend process exited with code ${code}`);
pythonBackend = null;
});

pythonBackend.on("error", (error) => {
console.error("Failed to start backend:", error)
dialog.showErrorBox(
"Backend Error",
`Failed to start backend: ${error.message}`,
)
})
pythonBackend.on('error', (error) => {
logFatal('Failed to start backend: ' + error);
dialog.showErrorBox('Backend Error', `Failed to start backend: ${error.message}`);
});
}

// Quit when all windows are closed, except on macOS. There, it's common
Expand All @@ -346,9 +271,7 @@ function closeWithBackend() {
win = null
}
destroyWebcamWindow()
destroyAboutWindow()
destroyLinkStatsWindow()
console.log("Killing backend")
logInfo('Killing backend')
// kill any processes with the name "fgcs_backend.exe"
// Windows
spawn("taskkill /f /im fgcs_backend.exe", { shell: true })
Expand All @@ -359,10 +282,10 @@ app.on("window-all-closed", () => {

// To ensure that the backend process is killed with Cmd + Q on macOS,
// listen to the before-quit event.
app.on("before-quit", () => {
if (process.platform === "darwin" && pythonBackend) {
console.log("Stopping backend")
spawnSync("pkill", ["-f", "fgcs_backend"])
app.on('before-quit', () => {
if(process.platform === 'darwin' && pythonBackend){
logInfo('Stopping backend')
spawnSync('pkill', ['-f', 'fgcs_backend']);
pythonBackend = null
destroyWebcamWindow()
destroyAboutWindow()
Expand All @@ -379,6 +302,14 @@ app.on("activate", () => {
})

app.whenReady().then(() => {

setupLog4js(
getSetting("Development", "logToWorkingDirectory"),
getSetting("Development", "combineLogs"),
getSetting("Development", "loggingFormat"),
getSetting("Development", "loggingLevel")
);

createLoadingWindow()
// Open file and Get Recent Logs
ipcMain.handle("fla:open-file", openFile)
Expand Down
Loading