1. 程式人生 > 實用技巧 >RN專案iOS報錯,Assertion failed: (severity >= 0 && severity < NUM_SEVERITIES)

RN專案iOS報錯,Assertion failed: (severity >= 0 && severity < NUM_SEVERITIES)

報錯資訊:

Assertion failed: (severity >= 0 && severity < NUM_SEVERITIES), function SetLogDestination,
 file /Users/samyao/Git/trace/node_modules/react-native/third-party/glog-0.3.4/src/logging.cc, line 595.

解決辦法:

inline void LogDestination::SetLogDestination(LogSeverity severity,
                          
const char* base_filename) { // assert(severity >= 0 && severity < NUM_SEVERITIES); char* base_filename_copy = nullptr; //初始化char*型別 base_filename_copy = const_cast<char*>(base_filename); //const char*型別轉char*型別 if (severity >= 0 && severity < NUM_SEVERITIES) {
// } else { severity = 0; base_filename_copy = const_cast<char*>("glogTest"); } // Prevent any subtle race conditions by wrapping a mutex lock around // all this stuff. MutexLock l(&log_mutex); //log_destination(severity)->fileobject_.SetBasename(base_filename); log_destination(severity)->fileobject_.SetBasename(base_filename_copy); }