os_unix.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. /*************************************************************************/
  2. /* os_unix.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "os_unix.h"
  31. #ifdef UNIX_ENABLED
  32. #include "core/config/project_settings.h"
  33. #include "core/debugger/engine_debugger.h"
  34. #include "core/debugger/script_debugger.h"
  35. #include "core/os/thread_dummy.h"
  36. #include "drivers/unix/dir_access_unix.h"
  37. #include "drivers/unix/file_access_unix.h"
  38. #include "drivers/unix/net_socket_posix.h"
  39. #include "drivers/unix/thread_posix.h"
  40. #include "servers/rendering_server.h"
  41. #ifdef __APPLE__
  42. #include <mach-o/dyld.h>
  43. #include <mach/mach_time.h>
  44. #endif
  45. #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
  46. #include <sys/param.h>
  47. #include <sys/sysctl.h>
  48. #endif
  49. #include <assert.h>
  50. #include <dlfcn.h>
  51. #include <errno.h>
  52. #include <poll.h>
  53. #include <signal.h>
  54. #include <stdarg.h>
  55. #include <stdio.h>
  56. #include <stdlib.h>
  57. #include <string.h>
  58. #include <sys/time.h>
  59. #include <sys/wait.h>
  60. #include <unistd.h>
  61. /// Clock Setup function (used by get_ticks_usec)
  62. static uint64_t _clock_start = 0;
  63. #if defined(__APPLE__)
  64. static double _clock_scale = 0;
  65. static void _setup_clock() {
  66. mach_timebase_info_data_t info;
  67. kern_return_t ret = mach_timebase_info(&info);
  68. ERR_FAIL_COND_MSG(ret != 0, "OS CLOCK IS NOT WORKING!");
  69. _clock_scale = ((double)info.numer / (double)info.denom) / 1000.0;
  70. _clock_start = mach_absolute_time() * _clock_scale;
  71. }
  72. #else
  73. #if defined(CLOCK_MONOTONIC_RAW) && !defined(JAVASCRIPT_ENABLED) // This is a better clock on Linux.
  74. #define GODOT_CLOCK CLOCK_MONOTONIC_RAW
  75. #else
  76. #define GODOT_CLOCK CLOCK_MONOTONIC
  77. #endif
  78. static void _setup_clock() {
  79. struct timespec tv_now = { 0, 0 };
  80. ERR_FAIL_COND_MSG(clock_gettime(GODOT_CLOCK, &tv_now) != 0, "OS CLOCK IS NOT WORKING!");
  81. _clock_start = ((uint64_t)tv_now.tv_nsec / 1000L) + (uint64_t)tv_now.tv_sec * 1000000L;
  82. }
  83. #endif
  84. void OS_Unix::debug_break() {
  85. assert(false);
  86. };
  87. static void handle_interrupt(int sig) {
  88. if (!EngineDebugger::is_active()) {
  89. return;
  90. }
  91. EngineDebugger::get_script_debugger()->set_depth(-1);
  92. EngineDebugger::get_script_debugger()->set_lines_left(1);
  93. }
  94. void OS_Unix::initialize_debugging() {
  95. if (EngineDebugger::is_active()) {
  96. struct sigaction action;
  97. memset(&action, 0, sizeof(action));
  98. action.sa_handler = handle_interrupt;
  99. sigaction(SIGINT, &action, nullptr);
  100. }
  101. }
  102. int OS_Unix::unix_initialize_audio(int p_audio_driver) {
  103. return 0;
  104. }
  105. void OS_Unix::initialize_core() {
  106. #ifdef NO_THREADS
  107. ThreadDummy::make_default();
  108. #else
  109. ThreadPosix::make_default();
  110. #endif
  111. FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_RESOURCES);
  112. FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_USERDATA);
  113. FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_FILESYSTEM);
  114. DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_RESOURCES);
  115. DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_USERDATA);
  116. DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_FILESYSTEM);
  117. #ifndef NO_NETWORK
  118. NetSocketPosix::make_default();
  119. IP_Unix::make_default();
  120. #endif
  121. _setup_clock();
  122. }
  123. void OS_Unix::finalize_core() {
  124. NetSocketPosix::cleanup();
  125. }
  126. void OS_Unix::alert(const String &p_alert, const String &p_title) {
  127. fprintf(stderr, "ERROR: %s\n", p_alert.utf8().get_data());
  128. }
  129. String OS_Unix::get_stdin_string(bool p_block) {
  130. if (p_block) {
  131. char buff[1024];
  132. String ret = stdin_buf + fgets(buff, 1024, stdin);
  133. stdin_buf = "";
  134. return ret;
  135. }
  136. return "";
  137. }
  138. String OS_Unix::get_name() const {
  139. return "Unix";
  140. }
  141. double OS_Unix::get_unix_time() const {
  142. struct timeval tv_now;
  143. gettimeofday(&tv_now, nullptr);
  144. return (double)tv_now.tv_sec + double(tv_now.tv_usec) / 1000000;
  145. };
  146. OS::Date OS_Unix::get_date(bool utc) const {
  147. time_t t = time(nullptr);
  148. struct tm lt;
  149. if (utc) {
  150. gmtime_r(&t, &lt);
  151. } else {
  152. localtime_r(&t, &lt);
  153. }
  154. Date ret;
  155. ret.year = 1900 + lt.tm_year;
  156. // Index starting at 1 to match OS_Unix::get_date
  157. // and Windows SYSTEMTIME and tm_mon follows the typical structure
  158. // of 0-11, noted here: http://www.cplusplus.com/reference/ctime/tm/
  159. ret.month = (Month)(lt.tm_mon + 1);
  160. ret.day = lt.tm_mday;
  161. ret.weekday = (Weekday)lt.tm_wday;
  162. ret.dst = lt.tm_isdst;
  163. return ret;
  164. }
  165. OS::Time OS_Unix::get_time(bool utc) const {
  166. time_t t = time(nullptr);
  167. struct tm lt;
  168. if (utc) {
  169. gmtime_r(&t, &lt);
  170. } else {
  171. localtime_r(&t, &lt);
  172. }
  173. Time ret;
  174. ret.hour = lt.tm_hour;
  175. ret.min = lt.tm_min;
  176. ret.sec = lt.tm_sec;
  177. get_time_zone_info();
  178. return ret;
  179. }
  180. OS::TimeZoneInfo OS_Unix::get_time_zone_info() const {
  181. time_t t = time(nullptr);
  182. struct tm lt;
  183. localtime_r(&t, &lt);
  184. char name[16];
  185. strftime(name, 16, "%Z", &lt);
  186. name[15] = 0;
  187. TimeZoneInfo ret;
  188. ret.name = name;
  189. char bias_buf[16];
  190. strftime(bias_buf, 16, "%z", &lt);
  191. int bias;
  192. bias_buf[15] = 0;
  193. sscanf(bias_buf, "%d", &bias);
  194. // convert from ISO 8601 (1 minute=1, 1 hour=100) to minutes
  195. int hour = (int)bias / 100;
  196. int minutes = bias % 100;
  197. if (bias < 0) {
  198. ret.bias = hour * 60 - minutes;
  199. } else {
  200. ret.bias = hour * 60 + minutes;
  201. }
  202. return ret;
  203. }
  204. void OS_Unix::delay_usec(uint32_t p_usec) const {
  205. struct timespec requested = { static_cast<time_t>(p_usec / 1000000), (static_cast<long>(p_usec) % 1000000) * 1000 };
  206. struct timespec remaining;
  207. while (nanosleep(&requested, &remaining) == -1 && errno == EINTR) {
  208. requested.tv_sec = remaining.tv_sec;
  209. requested.tv_nsec = remaining.tv_nsec;
  210. }
  211. }
  212. uint64_t OS_Unix::get_ticks_usec() const {
  213. #if defined(__APPLE__)
  214. uint64_t longtime = mach_absolute_time() * _clock_scale;
  215. #else
  216. // Unchecked return. Static analyzers might complain.
  217. // If _setup_clock() succeeded, we assume clock_gettime() works.
  218. struct timespec tv_now = { 0, 0 };
  219. clock_gettime(GODOT_CLOCK, &tv_now);
  220. uint64_t longtime = ((uint64_t)tv_now.tv_nsec / 1000L) + (uint64_t)tv_now.tv_sec * 1000000L;
  221. #endif
  222. longtime -= _clock_start;
  223. return longtime;
  224. }
  225. Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex) {
  226. #ifdef __EMSCRIPTEN__
  227. // Don't compile this code at all to avoid undefined references.
  228. // Actual virtual call goes to OS_JavaScript.
  229. ERR_FAIL_V(ERR_BUG);
  230. #else
  231. if (r_pipe) {
  232. String command = "\"" + p_path + "\"";
  233. for (int i = 0; i < p_arguments.size(); i++) {
  234. command += String(" \"") + p_arguments[i] + "\"";
  235. }
  236. if (read_stderr) {
  237. command += " 2>&1"; // Include stderr
  238. } else {
  239. command += " 2>/dev/null"; // Silence stderr
  240. }
  241. FILE *f = popen(command.utf8().get_data(), "r");
  242. ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, "Cannot create pipe from command: " + command);
  243. char buf[65535];
  244. while (fgets(buf, 65535, f)) {
  245. if (p_pipe_mutex) {
  246. p_pipe_mutex->lock();
  247. }
  248. (*r_pipe) += String::utf8(buf);
  249. if (p_pipe_mutex) {
  250. p_pipe_mutex->unlock();
  251. }
  252. }
  253. int rv = pclose(f);
  254. if (r_exitcode) {
  255. *r_exitcode = WEXITSTATUS(rv);
  256. }
  257. return OK;
  258. }
  259. pid_t pid = fork();
  260. ERR_FAIL_COND_V(pid < 0, ERR_CANT_FORK);
  261. if (pid == 0) {
  262. // The child process
  263. Vector<CharString> cs;
  264. cs.push_back(p_path.utf8());
  265. for (int i = 0; i < p_arguments.size(); i++) {
  266. cs.push_back(p_arguments[i].utf8());
  267. }
  268. Vector<char *> args;
  269. for (int i = 0; i < cs.size(); i++) {
  270. args.push_back((char *)cs[i].get_data());
  271. }
  272. args.push_back(0);
  273. execvp(p_path.utf8().get_data(), &args[0]);
  274. // The execvp() function only returns if an error occurs.
  275. ERR_PRINT("Could not create child process: " + p_path);
  276. raise(SIGKILL);
  277. }
  278. int status;
  279. waitpid(pid, &status, 0);
  280. if (r_exitcode) {
  281. *r_exitcode = WIFEXITED(status) ? WEXITSTATUS(status) : status;
  282. }
  283. return OK;
  284. #endif
  285. }
  286. Error OS_Unix::create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id) {
  287. #ifdef __EMSCRIPTEN__
  288. // Don't compile this code at all to avoid undefined references.
  289. // Actual virtual call goes to OS_JavaScript.
  290. ERR_FAIL_V(ERR_BUG);
  291. #else
  292. pid_t pid = fork();
  293. ERR_FAIL_COND_V(pid < 0, ERR_CANT_FORK);
  294. if (pid == 0) {
  295. // The new process
  296. // Create a new session-ID so parent won't wait for it.
  297. // This ensures the process won't go zombie at the end.
  298. setsid();
  299. Vector<CharString> cs;
  300. cs.push_back(p_path.utf8());
  301. for (int i = 0; i < p_arguments.size(); i++) {
  302. cs.push_back(p_arguments[i].utf8());
  303. }
  304. Vector<char *> args;
  305. for (int i = 0; i < cs.size(); i++) {
  306. args.push_back((char *)cs[i].get_data());
  307. }
  308. args.push_back(0);
  309. execvp(p_path.utf8().get_data(), &args[0]);
  310. // The execvp() function only returns if an error occurs.
  311. ERR_PRINT("Could not create child process: " + p_path);
  312. raise(SIGKILL);
  313. }
  314. if (r_child_id) {
  315. *r_child_id = pid;
  316. }
  317. return OK;
  318. #endif
  319. }
  320. Error OS_Unix::kill(const ProcessID &p_pid) {
  321. int ret = ::kill(p_pid, SIGKILL);
  322. if (!ret) {
  323. //avoid zombie process
  324. int st;
  325. ::waitpid(p_pid, &st, 0);
  326. }
  327. return ret ? ERR_INVALID_PARAMETER : OK;
  328. }
  329. int OS_Unix::get_process_id() const {
  330. return getpid();
  331. };
  332. bool OS_Unix::has_environment(const String &p_var) const {
  333. return getenv(p_var.utf8().get_data()) != nullptr;
  334. }
  335. String OS_Unix::get_locale() const {
  336. if (!has_environment("LANG")) {
  337. return "en";
  338. }
  339. String locale = get_environment("LANG");
  340. int tp = locale.find(".");
  341. if (tp != -1) {
  342. locale = locale.substr(0, tp);
  343. }
  344. return locale;
  345. }
  346. Error OS_Unix::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) {
  347. String path = p_path;
  348. if (FileAccess::exists(path) && path.is_rel_path()) {
  349. // dlopen expects a slash, in this case a leading ./ for it to be interpreted as a relative path,
  350. // otherwise it will end up searching various system directories for the lib instead and finally failing.
  351. path = "./" + path;
  352. }
  353. if (!FileAccess::exists(path)) {
  354. //this code exists so gdnative can load .so files from within the executable path
  355. path = get_executable_path().get_base_dir().plus_file(p_path.get_file());
  356. }
  357. if (!FileAccess::exists(path)) {
  358. //this code exists so gdnative can load .so files from a standard unix location
  359. path = get_executable_path().get_base_dir().plus_file("../lib").plus_file(p_path.get_file());
  360. }
  361. p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW);
  362. ERR_FAIL_COND_V_MSG(!p_library_handle, ERR_CANT_OPEN, "Can't open dynamic library: " + p_path + ". Error: " + dlerror());
  363. return OK;
  364. }
  365. Error OS_Unix::close_dynamic_library(void *p_library_handle) {
  366. if (dlclose(p_library_handle)) {
  367. return FAILED;
  368. }
  369. return OK;
  370. }
  371. Error OS_Unix::get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional) {
  372. const char *error;
  373. dlerror(); // Clear existing errors
  374. p_symbol_handle = dlsym(p_library_handle, p_name.utf8().get_data());
  375. error = dlerror();
  376. if (error != nullptr) {
  377. ERR_FAIL_COND_V_MSG(!p_optional, ERR_CANT_RESOLVE, "Can't resolve symbol " + p_name + ". Error: " + error + ".");
  378. return ERR_CANT_RESOLVE;
  379. }
  380. return OK;
  381. }
  382. Error OS_Unix::set_cwd(const String &p_cwd) {
  383. if (chdir(p_cwd.utf8().get_data()) != 0) {
  384. return ERR_CANT_OPEN;
  385. }
  386. return OK;
  387. }
  388. String OS_Unix::get_environment(const String &p_var) const {
  389. if (getenv(p_var.utf8().get_data())) {
  390. return getenv(p_var.utf8().get_data());
  391. }
  392. return "";
  393. }
  394. bool OS_Unix::set_environment(const String &p_var, const String &p_value) const {
  395. return setenv(p_var.utf8().get_data(), p_value.utf8().get_data(), /* overwrite: */ true) == 0;
  396. }
  397. int OS_Unix::get_processor_count() const {
  398. return sysconf(_SC_NPROCESSORS_CONF);
  399. }
  400. String OS_Unix::get_user_data_dir() const {
  401. String appname = get_safe_dir_name(ProjectSettings::get_singleton()->get("application/config/name"));
  402. if (appname != "") {
  403. bool use_custom_dir = ProjectSettings::get_singleton()->get("application/config/use_custom_user_dir");
  404. if (use_custom_dir) {
  405. String custom_dir = get_safe_dir_name(ProjectSettings::get_singleton()->get("application/config/custom_user_dir_name"), true);
  406. if (custom_dir == "") {
  407. custom_dir = appname;
  408. }
  409. return get_data_path().plus_file(custom_dir);
  410. } else {
  411. return get_data_path().plus_file(get_godot_dir_name()).plus_file("app_userdata").plus_file(appname);
  412. }
  413. }
  414. return ProjectSettings::get_singleton()->get_resource_path();
  415. }
  416. String OS_Unix::get_executable_path() const {
  417. #ifdef __linux__
  418. //fix for running from a symlink
  419. char buf[256];
  420. memset(buf, 0, 256);
  421. ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf));
  422. String b;
  423. if (len > 0) {
  424. b.parse_utf8(buf, len);
  425. }
  426. if (b == "") {
  427. WARN_PRINT("Couldn't get executable path from /proc/self/exe, using argv[0]");
  428. return OS::get_executable_path();
  429. }
  430. return b;
  431. #elif defined(__OpenBSD__) || defined(__NetBSD__)
  432. char resolved_path[MAXPATHLEN];
  433. realpath(OS::get_executable_path().utf8().get_data(), resolved_path);
  434. return String(resolved_path);
  435. #elif defined(__FreeBSD__)
  436. int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
  437. char buf[MAXPATHLEN];
  438. size_t len = sizeof(buf);
  439. if (sysctl(mib, 4, buf, &len, nullptr, 0) != 0) {
  440. WARN_PRINT("Couldn't get executable path from sysctl");
  441. return OS::get_executable_path();
  442. }
  443. String b;
  444. b.parse_utf8(buf);
  445. return b;
  446. #elif defined(__APPLE__)
  447. char temp_path[1];
  448. uint32_t buff_size = 1;
  449. _NSGetExecutablePath(temp_path, &buff_size);
  450. char *resolved_path = new char[buff_size + 1];
  451. if (_NSGetExecutablePath(resolved_path, &buff_size) == 1)
  452. WARN_PRINT("MAXPATHLEN is too small");
  453. String path(resolved_path);
  454. delete[] resolved_path;
  455. return path;
  456. #else
  457. ERR_PRINT("Warning, don't know how to obtain executable path on this OS! Please override this function properly.");
  458. return OS::get_executable_path();
  459. #endif
  460. }
  461. void UnixTerminalLogger::log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type) {
  462. if (!should_log(true)) {
  463. return;
  464. }
  465. const char *err_details;
  466. if (p_rationale && p_rationale[0]) {
  467. err_details = p_rationale;
  468. } else {
  469. err_details = p_code;
  470. }
  471. // Disable color codes if stdout is not a TTY.
  472. // This prevents Godot from writing ANSI escape codes when redirecting
  473. // stdout and stderr to a file.
  474. const bool tty = isatty(fileno(stdout));
  475. const char *gray = tty ? "\E[0;90m" : "";
  476. const char *red = tty ? "\E[0;91m" : "";
  477. const char *red_bold = tty ? "\E[1;31m" : "";
  478. const char *yellow = tty ? "\E[0;93m" : "";
  479. const char *yellow_bold = tty ? "\E[1;33m" : "";
  480. const char *magenta = tty ? "\E[0;95m" : "";
  481. const char *magenta_bold = tty ? "\E[1;35m" : "";
  482. const char *cyan = tty ? "\E[0;96m" : "";
  483. const char *cyan_bold = tty ? "\E[1;36m" : "";
  484. const char *reset = tty ? "\E[0m" : "";
  485. switch (p_type) {
  486. case ERR_WARNING:
  487. logf_error("%sWARNING:%s %s\n", yellow_bold, yellow, err_details);
  488. logf_error("%s at: %s (%s:%i)%s\n", gray, p_function, p_file, p_line, reset);
  489. break;
  490. case ERR_SCRIPT:
  491. logf_error("%sSCRIPT ERROR:%s %s\n", magenta_bold, magenta, err_details);
  492. logf_error("%s at: %s (%s:%i)%s\n", gray, p_function, p_file, p_line, reset);
  493. break;
  494. case ERR_SHADER:
  495. logf_error("%sSHADER ERROR:%s %s\n", cyan_bold, cyan, err_details);
  496. logf_error("%s at: %s (%s:%i)%s\n", gray, p_function, p_file, p_line, reset);
  497. break;
  498. case ERR_ERROR:
  499. default:
  500. logf_error("%sERROR:%s %s\n", red_bold, red, err_details);
  501. logf_error("%s at: %s (%s:%i)%s\n", gray, p_function, p_file, p_line, reset);
  502. break;
  503. }
  504. }
  505. UnixTerminalLogger::~UnixTerminalLogger() {}
  506. OS_Unix::OS_Unix() {
  507. Vector<Logger *> loggers;
  508. loggers.push_back(memnew(UnixTerminalLogger));
  509. _set_logger(memnew(CompositeLogger(loggers)));
  510. }
  511. #endif