void test_LOGGING_LEVEL_overrides_logging_level() { setenv( "LOGGING_LEVEL", "DEBUG", 1 ); set_logging_level( "critical" ); init_log( "tetris", get_trema_tmp(), LOGGING_TYPE_FILE ); assert_int_equal( LOG_DEBUG, get_logging_level() ); }
static list_element * lookup_flow_entries_with_table_id( const uint8_t table_id, const match *match, const uint16_t priority, const bool strict, const bool update_counters ) { assert( valid_table_id( table_id ) ); if ( get_logging_level() >= LOG_DEBUG ) { debug( "Looking up flow entries ( table_id = %#x, match = %p, priority = %u, strict = %s, update_counters = %s ).", table_id, match, priority, strict ? "true" : "false", update_counters ? "true" : "false" ); if ( match != NULL ) { dump_match( match, debug ); } } flow_table *table = get_flow_table( table_id ); if ( table == NULL ) { return NULL; } if ( update_counters ) { increment_lookup_count( table_id ); } list_element *head = NULL; create_list( &head ); for ( list_element *e = table->entries; e != NULL; e = e->next ) { flow_entry *entry = e->data; assert( entry != NULL ); if ( strict ) { if ( entry->priority < priority ) { break; } if ( priority == entry->priority && compare_match_strict( match, entry->match ) ) { if ( update_counters ) { increment_matched_count( table_id ); } append_to_tail( &head, entry ); break; } } else { if ( compare_match( match, entry->match ) ) { if ( update_counters ) { increment_matched_count( table_id ); } append_to_tail( &head, entry ); } } } return head; }
int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ /* ChibiOS initialization */ halInit(); chSysInit(); _start_watchdog(); /* Application specific initialization */ system_can_init(); system_serial_init(); _start_mco_output(); /* * Creates the processing threads. */ chThdCreateStatic(wa_STN1110_rx, sizeof(wa_STN1110_rx), NORMALPRIO, STN1110_rx, NULL); chThdCreateStatic(can_rx_wa, sizeof(can_rx_wa), NORMALPRIO, can_rx, NULL); uint32_t stats_check = 0; while (true) { chThdSleepMilliseconds(MAIN_THREAD_CHECK_INTERVAL_MS); enum logging_levels level = get_logging_level(); uint32_t stats_threshold = (level == logging_level_trace ? MAIN_THREAD_SLEEP_FINE_MS : MAIN_THREAD_SLEEP_NORMAL_MS); stats_check += MAIN_THREAD_CHECK_INTERVAL_MS; if (stats_check > stats_threshold) { broadcast_stats(); stats_check = 0; } if (WATCHDOG_ENABLED) wdgReset(&WDGD1); check_system_state(); } return 0; }
void test_set_logging_level_succeed() { set_logging_level( "critical" ); assert_int_equal( LOG_CRITICAL, get_logging_level() ); }
void test_default_logging_level_is_INFO() { assert_int_equal( LOG_INFO, get_logging_level() ); }
void test_init_log_reads_LOGING_LEVEL_environment_variable() { setenv( "LOGGING_LEVEL", "CRITICAL", 1 ); init_log( "tetris", get_trema_tmp(), false ); assert_int_equal( LOG_CRITICAL, get_logging_level() ); }
void test_set_logging_level_is_called_before_init_log() { set_logging_level( "critical" ); init_log( "tetris", get_trema_tmp(), LOGGING_TYPE_FILE ); assert_int_equal( LOG_CRIT, get_logging_level() ); }
void Http::priv::http_perform() { ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writecb); ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, static_cast<void*>(this)); ::curl_easy_setopt(curl, CURLOPT_READFUNCTION, form_file_read_cb); ::curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); #if LIBCURL_VERSION_MAJOR >= 7 && LIBCURL_VERSION_MINOR >= 32 ::curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, xfercb); ::curl_easy_setopt(curl, CURLOPT_XFERINFODATA, static_cast<void*>(this)); #ifndef _WIN32 (void)xfercb_legacy; // prevent unused function warning #endif #else ::curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, xfercb); ::curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, static_cast<void*>(this)); #endif ::curl_easy_setopt(curl, CURLOPT_VERBOSE, get_logging_level() >= 4); if (headerlist != nullptr) { ::curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); } if (form != nullptr) { ::curl_easy_setopt(curl, CURLOPT_HTTPPOST, form); } if (!postfields.empty()) { ::curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postfields.c_str()); ::curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, postfields.size()); } CURLcode res = ::curl_easy_perform(curl); if (res != CURLE_OK) { if (res == CURLE_ABORTED_BY_CALLBACK) { if (cancel) { // The abort comes from the request being cancelled programatically Progress dummyprogress(0, 0, 0, 0); bool cancel = true; if (progressfn) { progressfn(dummyprogress, cancel); } } else { // The abort comes from the CURLOPT_READFUNCTION callback, which means reading file failed if (errorfn) { errorfn(std::move(buffer), "Error reading file for file upload", 0); } } } else if (res == CURLE_WRITE_ERROR) { if (errorfn) { errorfn(std::move(buffer), body_size_error(), 0); } } else { if (errorfn) { errorfn(std::move(buffer), curl_error(res), 0); } }; } else { long http_status = 0; ::curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_status); if (http_status >= 400) { if (errorfn) { errorfn(std::move(buffer), std::string(), http_status); } } else { if (completefn) { completefn(std::move(buffer), http_status); } } } }