| 42 | const ForyLogLevel fory_severity_threshold = ForyLog::get_log_level(); |
| 43 | |
| 44 | std::string get_call_trace() { |
| 45 | #if !defined(_WIN32) |
| 46 | std::array<void *, 100> local_stack{}; |
| 47 | int frames = |
| 48 | backtrace(local_stack.data(), static_cast<int>(local_stack.size())); |
| 49 | std::string output; |
| 50 | char **symbols = backtrace_symbols(local_stack.data(), frames); |
| 51 | if (symbols != nullptr) { |
| 52 | for (int i = 0; i < frames; ++i) { |
| 53 | output.append(" ").append(symbols[i]).append("\n"); |
| 54 | } |
| 55 | std::free(symbols); |
| 56 | return output; |
| 57 | } |
| 58 | for (int i = 0; i < frames; ++i) { |
| 59 | std::ostringstream stream; |
| 60 | stream << " frame[" << i << "] " << local_stack[static_cast<size_t>(i)] |
| 61 | << "\n"; |
| 62 | output.append(stream.str()); |
| 63 | } |
| 64 | return output; |
| 65 | #else |
| 66 | std::string output = " Stack trace is not supported on this platform.\n"; |
| 67 | return output; |
| 68 | #endif |
| 69 | } |
| 70 | |
| 71 | std::unordered_map<ForyLogLevel, std::string> log_level_to_str = { |
| 72 | {ForyLogLevel::FORY_DEBUG, "DEBUG"}, |