Working on linux now, better logging
This commit is contained in:
@@ -7,8 +7,12 @@
|
||||
#include <windows.h>
|
||||
#include <filesystem>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <spawn.h>
|
||||
#include <filesystem>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
@@ -101,7 +105,7 @@ bool runRktWebview(Handle_t *handler)
|
||||
sa.bInheritHandle = TRUE;
|
||||
|
||||
HANDLE h = CreateFile(logfile.c_str(),
|
||||
FILE_APPEND_DATA,
|
||||
0, //FILE_APPEND_DATA,
|
||||
FILE_SHARE_WRITE | FILE_SHARE_READ,
|
||||
&sa,
|
||||
OPEN_ALWAYS,
|
||||
@@ -137,7 +141,19 @@ bool runRktWebview(Handle_t *handler)
|
||||
#else
|
||||
char *argv[] = { rkt_webview_prg_path, const_cast<char *>(handler->name.c_str()), shm_size_str, command_slot, command_result_slot, event_slot, nullptr };
|
||||
|
||||
int r = posix_spawn(&handler->rkt_webview_prg_pid, rkt_webview_prg_path, nullptr, nullptr, argv, environ);
|
||||
struct passwd *pw = getpwuid(getuid());
|
||||
const char *homedir = pw->pw_dir;
|
||||
|
||||
std::string log_file = std::string(homedir) + "/.racket-webview.log";
|
||||
|
||||
posix_spawn_file_actions_t action;
|
||||
posix_spawn_file_actions_init(&action);
|
||||
posix_spawn_file_actions_addopen(&action, STDOUT_FILENO, log_file.c_str(), O_CREAT|O_WRONLY, 0600);
|
||||
posix_spawn_file_actions_addopen(&action, STDERR_FILENO, log_file.c_str(), O_WRONLY|O_APPEND, 0600);
|
||||
|
||||
int r = posix_spawn(&handler->rkt_webview_prg_pid, rkt_webview_prg_path, &action, nullptr, argv, environ);
|
||||
|
||||
posix_spawn_file_actions_destroy(&action);
|
||||
|
||||
return (r == 0);
|
||||
#endif
|
||||
@@ -443,6 +459,15 @@ result_t rkt_webview_show_normal(rktwebview_t w)
|
||||
CMDRES0(CMD_SHOW_NORMAL, w)
|
||||
}
|
||||
|
||||
void rkt_webview_set_loglevel(rkt_webview_loglevel_t l)
|
||||
{
|
||||
auto f = [l]() {
|
||||
CMDRES0(CMD_SET_LOGLEVEL, static_cast<int>(l));
|
||||
};
|
||||
f();
|
||||
}
|
||||
|
||||
|
||||
window_state_t rkt_webview_window_state(rktwebview_t w)
|
||||
{
|
||||
auto f = [w]() {
|
||||
@@ -550,7 +575,8 @@ void rkt_webview_env(const char *env_cmds[])
|
||||
#ifdef WIN32
|
||||
_putenv(env_cmds[i]);
|
||||
#else
|
||||
putenv(env_cmds[i]);
|
||||
putenv(const_cast<char *>(env_cmds[i]));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user