void global_logger_destroy(){ if (!G_LOGGER){ return; } logger_destroy(G_LOGGER); G_LOGGER = nullptr; }
void reactor_destroy(Reactor *u) { demux_destroy(u->demux); logger_destroy(u->logger); memset(u, 0, sizeof(Reactor)); free(u); }
str logger_destroy_wrap(void *ret, logger *L ) { logger *l = *(logger**)L; (void) ret; if (l) { logger_destroy(l); return MAL_SUCCEED; } throw(MAL, "logger.destroy", OPERATION_FAILED); }
static void bl_destroy(void) { logger *l = restrict_logger; restrict_logger = NULL; if (l) { logger_exit(l); logger_destroy(l); } }
int main(int argc, char* argv[]) { Logger* stderr_logger = stderr_logger_create(); logger_set_next(stderr_logger, stdout_logger_create()); logger_message(stderr_logger, "information", DEBUG); logger_message(stderr_logger, "Notice", NOTICE); logger_message(stderr_logger, "Error", ERR); logger_destroy(stderr_logger); return 0; }
void raop_destroy(raop_t *raop) { if (raop) { raop_stop(raop); httpd_destroy(raop->httpd); rsakey_destroy(raop->rsakey); logger_destroy(raop->logger); free(raop); /* Cleanup the network */ netutils_cleanup(); } }
/** * This will terminate a libtgdb session. No functions should be called on * the tgdb context passed into this function after this call. * * \param tgdb * An instance of the tgdb library to operate on. * * @return * 0 on success or -1 on error */ int Ctgdb::Shutdown() { /* Free the logger */ if (num_loggers == 1) { if (logger_destroy (m_logger) == -1) { printf ("Could not destroy logger interface\n"); return -1; } } --num_loggers; isInitiolized = false; return tgdb_client_destroy_context(tcc); }
int logger_init(Logger *logger, int mode, const char *log_conf_path, const char *log_file_dir) { int rc; zlog_category_t *zc; logger->log_i = my_zlog_info; logger->log_d = my_zlog_debug; logger->log_e = my_zlog_error; int ret = make_config(log_conf_path, log_file_dir); if (ret < 0) { goto ERROR; } rc = zlog_init(log_conf_path); if (rc) { fprintf(stderr, "logger_init: zlog_init error\n"); goto ERROR; } if (mode == LOG_STDOUT) { zc = zlog_get_category("stdout"); } else if (mode == LOG_FILE) { zc = zlog_get_category("file"); } if (!zc) { fprintf(stderr, "logger_init: zlog_get_category error\n"); goto ERROR; } logger->zc = zc; logger->log_mode = mode; logger->log_on = 1; s_init_zlog_success = 1; return 0; ERROR: logger_destroy(logger); return -1; }
void teardown(void) { int rc; //empty event queue queue_dispose_queue(event_queue); LOG_DEBUG(TEST_SIPSTACK_PREFIX "Event queue emptied successfully."); rc = tm_destroy(0); fail_if(rc == 0, "thread management could not be released"); rc = logger_destroy(); fail_if(rc == 0, "logger could not be released"); rc = cr_destroy(); fail_if(rc == 0, "config reader could not be released"); }
int main(void) { t_logger *logger; t_queue *queue; int a; int *b; a = 5; queue = queue_create(); if (queue_enqueue(queue, &a) < 0) return (-1); b = (int *)queue_dequeue(queue); queue_destroy(queue); logger = logger_create(); logger_write("Ceci est une gestion d\'erreur.\n"); logger_destroy(); return (0); }
static void quit(struct app_runtime_t *app) { if (app->onDestory != NULL) { app->onDestory(app); } if (app->task_manager != NULL) { app->task_manager->destory(app->task_manager); } appe_message_queue_destory(app->msg_queue); appe_looper_exit(app->looper); if (app->tcp_server_groups != NULL) { app->tcp_server_groups->destroy(app->tcp_server_groups); } if (app->tcp_slave_groups != NULL) { app->tcp_slave_groups->destroy(app->tcp_slave_groups); } logger_destroy(&s_logger); }
int main(int argc, char *argv[]) { int ret = EX_OK; primwatch_t primwatch; const char *log_type; const char *log_facility; const char *log_prefix; char log_path[MAXPATHLEN]; const char *pid_file_path; const char *cntrl_addr; const char *cntrl_port; int64_t verbose_level; if (logger_create()) { fprintf(stderr, "failed in create logger"); ret = EX_OSERR; } if (primwatch_initialize(&primwatch)) { fprintf(stderr, "failed in initaizliae"); ret = EX_OSERR; goto last; } parse_args(&primwatch, argc, argv); if (logger_set_foreground(primwatch.foreground)) { fprintf(stderr, "failed in create logger"); ret = EX_OSERR; } if (config_manager_load(primwatch.config_manager, primwatch.config_file)) { LOG(LOG_LV_ERR, "failed in load config file %s", primwatch.config_file); ret = EX_DATAERR; goto last; } if (config_manager_get_string(primwatch.config_manager, &log_type , "logType", NULL)) { LOG(LOG_LV_ERR, "failed in get log type from config"); ret = EX_DATAERR; goto last; } if (config_manager_get_string(primwatch.config_manager, &log_facility , "logFacility", NULL)) { LOG(LOG_LV_ERR, "failed in get log facility from config"); ret = EX_DATAERR; goto last; } if (config_manager_get_string(primwatch.config_manager, &log_prefix , "logPath", NULL)) { LOG(LOG_LV_ERR, "failed in get log path from config"); ret = EX_DATAERR; goto last; } if (config_manager_get_string(primwatch.config_manager, &pid_file_path , "pidFilePath", NULL)) { LOG(LOG_LV_ERR, "failed in get pid file path from config"); ret = EX_DATAERR; goto last; } if (config_manager_get_string(primwatch.config_manager, &cntrl_addr , "controllerAddress", NULL)) { LOG(LOG_LV_ERR, "failed in get controller address from config"); ret = EX_DATAERR; goto last; } if (config_manager_get_string(primwatch.config_manager, &cntrl_port , "controllerPort", NULL)) { LOG(LOG_LV_ERR, "failed in get controller port from config"); ret = EX_DATAERR; goto last; } if (config_manager_get_long(primwatch.config_manager, &verbose_level , "verboseLevel", NULL)) { LOG(LOG_LV_ERR, "failed in get verbose level from config"); ret = EX_DATAERR; goto last; } snprintf(log_path, sizeof(log_path), "%s.daemon", log_prefix); if (logger_open((log_level_t)verbose_level, log_type, PROGIDENT, LOG_PID, log_facility, log_path)) { LOG(LOG_LV_ERR, "failed in open log"); ret = EX_OSERR; goto last; } if (!primwatch.foreground) { if (daemon(1,1)) { LOG(LOG_LV_ERR, "failed in daemon"); ret = EX_OSERR; goto last; } setsid(); } if (primwatch_event_initialize(&primwatch)) { fprintf(stderr, "failed in initaizliae"); ret = EX_OSERR; goto last; } if (make_pidfile(pid_file_path)) { LOG(LOG_LV_ERR, "failed in create file of process id"); ret = EX_OSERR; goto last; } if (watcher_polling_start(primwatch.watcher)) { LOG(LOG_LV_ERR, "failed in initial polling"); ret = EX_OSERR; goto last; } if (controller_start(primwatch.controller, cntrl_addr, cntrl_port)) { LOG(LOG_LV_ERR, "failed in start controller"); ret = EX_OSERR; goto last; } signal_set(&primwatch.sig_int_event, SIGINT, primwatch_terminate, &primwatch); event_priority_set(&primwatch.sig_int_event, DEFAULT_EVENT_PRIORITY + 30); event_base_set(primwatch.event_base, &primwatch.sig_int_event); signal_add(&primwatch.sig_int_event, NULL); signal_set(&primwatch.sig_term_event, SIGTERM, primwatch_terminate, &primwatch); event_priority_set(&primwatch.sig_term_event, DEFAULT_EVENT_PRIORITY + 30); event_base_set(primwatch.event_base, &primwatch.sig_term_event); signal_add(&primwatch.sig_term_event, NULL); signal_set(&primwatch.sig_hup_event, SIGHUP, primwatch_reload, &primwatch); event_priority_set(&primwatch.sig_hup_event, DEFAULT_EVENT_PRIORITY + 30); event_base_set(primwatch.event_base, &primwatch.sig_hup_event); signal_add(&primwatch.sig_hup_event, NULL); signal_set(&primwatch.sig_chld_event, SIGCHLD, primwatch_sigchild, &primwatch); event_priority_set(&primwatch.sig_chld_event, DEFAULT_EVENT_PRIORITY + 30); event_base_set(primwatch.event_base, &primwatch.sig_chld_event); signal_add(&primwatch.sig_chld_event, NULL); if (event_base_dispatch(primwatch.event_base) == -1) { LOG(LOG_LV_ERR, "failed in event base dispatch"); ret = EX_OSERR; goto last; } last: unlink(pid_file_path); logger_close(); logger_destroy(); primwatch_finalize(&primwatch); return ret; }
/*{{{ application_destroy */ static void application_destroy (Application *app) { LOG_debug (APP_LOG, "Destroying application !"); g_free (app->conf_path); if (app->read_client_pool) client_pool_destroy (app->read_client_pool); if (app->write_client_pool) client_pool_destroy (app->write_client_pool); if (app->ops_client_pool) client_pool_destroy (app->ops_client_pool); if (app->dir_tree) dir_tree_destroy (app->dir_tree); if (app->cmng) cache_mng_destroy (app->cmng); if (app->sigint_ev) event_free (app->sigint_ev); if (app->sigterm_ev) event_free (app->sigterm_ev); if (app->sigpipe_ev) event_free (app->sigpipe_ev); if (app->sigusr1_ev) event_free (app->sigusr1_ev); if (app->sigusr2_ev) event_free (app->sigusr2_ev); if (app->service_con) http_connection_destroy (app->service_con); if (app->stat_srv) stat_srv_destroy (app->stat_srv); // destroy Fuse if (app->rfuse) rfuse_destroy (app->rfuse); if (app->dns_base) evdns_base_free (app->dns_base, 0); if (app->evbase) event_base_free (app->evbase); if (app->uri) evhttp_uri_free (app->uri); if (app->conf) conf_destroy (app->conf); if (app->fuse_opts) g_free (app->fuse_opts); #ifdef SSL_ENABLED SSL_CTX_free (app->ssl_ctx); #endif #ifdef MAGIC_ENABLED magic_close(app->magic_ctx); #endif logger_destroy (); if (app->f_log) fclose (app->f_log); if (app->log_file_name) g_free (app->log_file_name); g_free (app); ENGINE_cleanup (); CRYPTO_cleanup_all_ex_data (); ERR_free_strings (); ERR_remove_thread_state (NULL); EVP_cleanup (); }
int main(int argc, char** argv) { int response; igraph_t graph; igraph_vector_ptr_t complist; iclust_collection * collection = NULL; time_t time_start, time_end; /* turn on attribute handling */ igraph_i_set_attribute_table(&igraph_cattribute_table); double minimal_weight; unsigned int maximal_steps_delimieter; char graphncol[1024], logconfig[1024]; Config *cfg = ConfigNew(); const char * configuration = getopt_configfile(argc, argv, "./graphtocluster.conf"); massert((ConfigReadFile(configuration, &cfg) == CONFIG_OK), "Configuration file is not readable"); ConfigReadString(cfg, "sources", "graphncol", graphncol, sizeof(graphncol), 0); ConfigReadString(cfg, "sources", "logconfig", logconfig, sizeof(logconfig), 0); ConfigReadDouble(cfg, "limits", "minimal_weight", &minimal_weight, 0); ConfigReadUnsignedInt(cfg, "limits", "maximal_steps_delimieter", &maximal_steps_delimieter, 1); massert((maximal_steps_delimieter > 0), "Delimiter can not be equal to zero"); ConfigFree(cfg); logger_init(logconfig, "graphtocluster"); logger_info("File:\t configuration %s", configuration); logger_info("File:\t configuration logger %s", logconfig); logger_info("File:\t ncol graph source %s", graphncol); logger_info("Min:\t edge weight %f", minimal_weight); logger_info("Max:\t step delimeter %u", maximal_steps_delimieter); FILE *graph_source = fopen(graphncol, "r"); response = igraph_read_graph_ncol(&graph, graph_source, NULL, true, IGRAPH_ADD_WEIGHTS_YES, 0); massert((response == IGRAPH_SUCCESS), "Can not read a graph"); logger_info("Count:\t edges at start: %d", igraph_ecount(&graph)); fclose(graph_source); time(&time_start); igraph_edges_remove_by(&graph, "weight", minimal_weight, double_lt); time(&time_end); logger_info("Time:\t remove edges: %f", difftime(time_end, time_start)); logger_info("Count:\t edges after remove: %d", igraph_ecount(&graph)); response = igraph_vector_ptr_init(&complist, 0); massert((response == IGRAPH_SUCCESS), "Can not initialize vector pointer"); response = igraph_decompose(&graph, &complist, IGRAPH_WEAK, -1, 0); massert((response == IGRAPH_SUCCESS), "Can not decompose graph"); unsigned int n = igraph_vector_ptr_size(&complist); collection = iclust_collection_new(); massert((collection != NULL), "Cluster collection object can not be empty"); time(&time_start); for (unsigned int i = 0; i < n; i++) { igraph_t *subgraph = VECTOR(complist)[i]; massert((subgraph != NULL), "Subgraph object can not be empty"); iclust_collection_fill_leading_eigenvector(collection, subgraph, (i + 1), maximal_steps_delimieter); igraph_destroy(subgraph); } time(&time_end); logger_info("Time:\t cluster: %f", difftime(time_end, time_start)); /* Sort collection by cluster id to be * able to build a second column correct*/ time(&time_start); iclust_collection_sort(collection); time(&time_end); logger_info("Time:\t cluster sorting: %f", difftime(time_end, time_start)); unsigned long cluster_index = 1, cluster = 0; for (unsigned long i = 0; i < collection->length; i++) { iclust_collection_element * element = collection->collection[i]; massert((element != NULL), "Cluster collection element object can not be empty"); if (element->cluster != cluster) { cluster = element->cluster; cluster_index = 0; } printf("%lu\t%lu\t%s\n", cluster, ++cluster_index, element->name); } iclust_collection_destroy(collection); igraph_vector_ptr_destroy(&complist); igraph_destroy(&graph); logger_destroy(); return EXIT_SUCCESS; }