mirror of
https://git.sanhost.net/sanasol/hytale-f2p.git
synced 2026-02-25 22:31:46 -03:00
Add Send Logs button for one-click log submission to support
Collects launcher logs, game client logs, and config snapshot into a ZIP file and uploads to auth server. Shows submission ID for sharing with support. Includes i18n for all 11 locales.
This commit is contained in:
77
main.js
77
main.js
@@ -1407,6 +1407,83 @@ ipcMain.handle('get-recent-logs', async (event, maxLines = 100) => {
|
||||
|
||||
|
||||
|
||||
ipcMain.handle('send-logs', async () => {
|
||||
try {
|
||||
const https = require('https');
|
||||
const http = require('http');
|
||||
const { collectLogs, createZipBuffer } = require('./backend/utils/logCollector');
|
||||
|
||||
const { files, meta } = collectLogs();
|
||||
if (files.length === 0) {
|
||||
return { success: false, error: 'No log files found' };
|
||||
}
|
||||
|
||||
// Create ZIP with individual log files
|
||||
const zipBuffer = createZipBuffer(files);
|
||||
|
||||
// Get auth server URL from core config
|
||||
const { getAuthServerUrl } = require('./backend/core/config');
|
||||
const authUrl = getAuthServerUrl();
|
||||
|
||||
// Build file names list
|
||||
const fileNames = files.map(f => f.name).join(',');
|
||||
|
||||
return await new Promise((resolve) => {
|
||||
const url = new URL(authUrl + '/logs/submit');
|
||||
const transport = url.protocol === 'https:' ? https : http;
|
||||
|
||||
const options = {
|
||||
hostname: url.hostname,
|
||||
port: url.port || (url.protocol === 'https:' ? 443 : 80),
|
||||
path: url.pathname,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/zip',
|
||||
'Content-Length': zipBuffer.length,
|
||||
'X-Log-Username': meta.username || 'unknown',
|
||||
'X-Log-Platform': meta.platform || 'unknown',
|
||||
'X-Log-Version': meta.version || 'unknown',
|
||||
'X-Log-File-Count': String(files.length),
|
||||
'X-Log-Files': fileNames
|
||||
},
|
||||
timeout: 30000
|
||||
};
|
||||
|
||||
const req = transport.request(options, (res) => {
|
||||
let body = '';
|
||||
res.on('data', (chunk) => body += chunk);
|
||||
res.on('end', () => {
|
||||
try {
|
||||
const data = JSON.parse(body);
|
||||
if (res.statusCode === 200) {
|
||||
resolve({ success: true, id: data.id, message: data.message });
|
||||
} else {
|
||||
resolve({ success: false, error: data.error || `Server error ${res.statusCode}` });
|
||||
}
|
||||
} catch (e) {
|
||||
resolve({ success: false, error: `Invalid response: ${res.statusCode}` });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
req.on('error', (err) => {
|
||||
resolve({ success: false, error: err.message });
|
||||
});
|
||||
|
||||
req.on('timeout', () => {
|
||||
req.destroy();
|
||||
resolve({ success: false, error: 'Request timed out' });
|
||||
});
|
||||
|
||||
req.write(zipBuffer);
|
||||
req.end();
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error sending logs:', error);
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('open-logs-folder', async () => {
|
||||
try {
|
||||
const logDir = logger.getLogDirectory();
|
||||
|
||||
Reference in New Issue
Block a user