mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-07-30 12:34:26 +00:00
add socket events to emit console messages
This commit is contained in:
@@ -207,6 +207,27 @@ namespace ElectronNET.API
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Log a message to the console output pipe. This is used when running with "detachedProcess" : true on the electron.manifest.json,
|
||||
/// as in that case we can't open pipes to read the console output from the child process anymore
|
||||
/// </summary>
|
||||
/// <param name="text">Message to log</param>
|
||||
public static void ConsoleLog(string text)
|
||||
{
|
||||
BridgeConnector.Emit("console-stdout", text);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Log a message to the console error pipe. This is used when running with "detachedProcess" : true on the electron.manifest.json,
|
||||
/// as in that case we can't open pipes to read the console output from the child process anymore
|
||||
/// </summary>
|
||||
/// <param name="text">Message to log</param>
|
||||
|
||||
public static void ConsoleError(string text)
|
||||
{
|
||||
BridgeConnector.Emit("console-stderr", text);
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
|
||||
@@ -271,6 +271,14 @@ function startSocketApiBridge(port) {
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('console-stdout', (data) => {
|
||||
console.log(`stdout: ${data.toString()}`);
|
||||
});
|
||||
|
||||
socket.on('console-stderr', (data) => {
|
||||
console.log(`stderr: ${data.toString()}`);
|
||||
});
|
||||
|
||||
try {
|
||||
const hostHookScriptFilePath = path.join(__dirname, 'ElectronHostHook', 'index.js');
|
||||
|
||||
@@ -320,7 +328,7 @@ function startAspCoreBackend(electronPort) {
|
||||
if (manifestJsonFile.hasOwnProperty('detachedProcess')) {
|
||||
detachedProcess = manifestJsonFile.detachedProcess;
|
||||
if (detachedProcess) {
|
||||
stdioopt = ['ignore', 'pipe', 'pipe'];
|
||||
stdioopt = 'ignore';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,7 +384,7 @@ function startAspCoreBackendWithWatch(electronPort) {
|
||||
if (manifestJsonFile.hasOwnProperty('detachedProcess')) {
|
||||
detachedProcess = manifestJsonFile.detachedProcess;
|
||||
if (detachedProcess) {
|
||||
stdioopt = ['ignore', 'pipe', 'pipe'];
|
||||
stdioopt = 'ignore';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user