MCPcopy Create free account
hub / github.com/dobin/RedEdr / init

Function init

RedEdrShared/loguru.cpp:607–680  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

605 }
606
607 void init(int& argc, char* argv[], const Options& options)
608 {
609 CHECK_GT_F(argc, 0, "Expected proper argc/argv");
610 CHECK_EQ_F(argv[argc], nullptr, "Expected proper argc/argv");
611
612 s_argv0_filename = filename(argv[0]);
613
614#ifdef _WIN32
615#define getcwd _getcwd
616#endif
617
618 if (!getcwd(s_current_dir, sizeof(s_current_dir))) {
619 const auto error_text = errno_as_text();
620 LOG_F(WARNING, "Failed to get current working directory: " LOGURU_FMT(s) "", error_text.c_str());
621 }
622
623 s_arguments = "";
624 for (int i = 0; i < argc; ++i) {
625 escape(s_arguments, argv[i]);
626 if (i + 1 < argc) {
627 s_arguments += " ";
628 }
629 }
630
631 if (options.verbosity_flag) {
632 parse_args(argc, argv, options.verbosity_flag);
633 }
634
635 if (const auto main_thread_name = options.main_thread_name) {
636#if LOGURU_PTLS_NAMES || LOGURU_WINTHREADS
637 set_thread_name(main_thread_name);
638#elif LOGURU_PTHREADS
639 char old_thread_name[16] = { 0 };
640 auto this_thread = pthread_self();
641#if defined(__APPLE__) || defined(__linux__) || defined(__sun)
642 pthread_getname_np(this_thread, old_thread_name, sizeof(old_thread_name));
643#endif
644 if (old_thread_name[0] == 0) {
645#ifdef __APPLE__
646 pthread_setname_np(main_thread_name);
647#elif defined(__FreeBSD__) || defined(__OpenBSD__)
648 pthread_set_name_np(this_thread, main_thread_name);
649#elif defined(__linux__) || defined(__sun)
650 pthread_setname_np(this_thread, main_thread_name);
651#endif
652 }
653#endif // LOGURU_PTHREADS
654 }
655
656 if (g_stderr_verbosity >= Verbosity_INFO) {
657 if (g_preamble_header) {
658 char preamble_explain[LOGURU_PREAMBLE_WIDTH];
659 print_preamble_header(preamble_explain, sizeof(preamble_explain));
660 if (g_colorlogtostderr && s_terminal_has_color) {
661 fprintf(stderr, "%s%s%s\n", terminal_reset(), terminal_dim(), preamble_explain);
662 }
663 else {
664 fprintf(stderr, "%s\n", preamble_explain);

Callers 3

JsonWMethod · 0.85
jsonMethod · 0.85
ResetDataMethod · 0.85

Calls 9

filenameFunction · 0.85
errno_as_textFunction · 0.85
parse_argsFunction · 0.85
set_thread_nameFunction · 0.85
print_preamble_headerFunction · 0.85
terminal_resetFunction · 0.85
terminal_dimFunction · 0.85
install_signal_handlersFunction · 0.85
escapeFunction · 0.70

Tested by

no test coverage detected