void cs_reopen_log(void) { if(cfg.logfile) { if(fp) { fprintf(fp, "flush and re-open log file\n"); fflush(fp); fclose(fp); fp = NULL; } if(cs_open_logfiles()) { fprintf(stderr, "Initialisation of log file failed, continuing without logging thread %8luX. Log will be output to stdout!", (unsigned long)pthread_self()); cfg.logtostdout = 1; } } if(cfg.usrfile) { if(fps) { fprintf(fps, "flush and re-open user log file\n"); fflush(fps); fclose(fps); fps = NULL; } if(cs_init_statistics()) { fprintf(stderr, "Initialisation of user log file failed, continuing without logging thread %8luX.", (unsigned long)pthread_self()); } } }
int32_t cs_init_log(void) { if(logStarted == 0) { pthread_mutex_init(&log_mutex, NULL); cs_pthread_cond_init(&log_thread_sleep_cond_mutex, &log_thread_sleep_cond); #if defined(WEBIF) || defined(MODULE_MONITOR) cs_lock_create(&loghistory_lock, "loghistory_lock", 5000); #endif log_list = ll_create(LOG_LIST); pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, PTHREAD_STACK_SIZE); int32_t ret = pthread_create(&log_thread, &attr, (void *)&log_list_thread, NULL); if(ret) { fprintf(stderr, "ERROR: Can't create logging thread (errno=%d %s)", ret, strerror(ret)); pthread_attr_destroy(&attr); cs_exit(1); } pthread_attr_destroy(&attr); } int32_t rc = 0; if(!cfg.disablelog) { rc = cs_open_logfiles(); } logStarted = 1; return rc; }
void cs_disable_log(int8_t disabled) { if(cfg.disablelog != disabled) { if(disabled && logStarted) { cs_log("Stopping log..."); log_list_flush(); } cfg.disablelog = disabled; if(disabled) { if(logStarted) { if(syslog_socket != -1) { close(syslog_socket); syslog_socket = -1; } cs_sleepms(20); cs_close_log(); } } else { init_syslog_socket(); cs_open_logfiles(); } } }
int32_t cs_init_log(void) { if(logStarted == 0) { init_syslog_socket(); SAFE_MUTEX_INIT_NOLOG(&log_mutex, NULL); cs_pthread_cond_init_nolog(__func__, &log_thread_sleep_cond_mutex, &log_thread_sleep_cond); #if defined(WEBIF) || defined(MODULE_MONITOR) cs_lock_create_nolog(__func__, &loghistory_lock, "loghistory_lock", 5000); #endif log_list = ll_create(LOG_LIST); int32_t ret = start_thread_nolog("logging", (void *)&log_list_thread, NULL, &log_thread, 0, 1); if(ret) { cs_exit(1); } logStarted = 1; } int32_t rc = 0; if(!cfg.disablelog) { rc = cs_open_logfiles(); } logStarted = 1; if(cfg.initial_debuglevel > 0) { cs_dblevel = cfg.initial_debuglevel; cs_log("debug_level=%d", cs_dblevel); } return rc; }
int32_t cs_init_log(void) { if(logStarted == 0){ #if defined(WEBIF) || defined(MODULE_MONITOR) cs_lock_create(&loghistory_lock, 5, "loghistory_lock"); #endif log_list = ll_create(LOG_LIST); start_thread((void*)&log_list_thread, "log_list_thread"); } int32_t rc = cs_open_logfiles(); logStarted = 1; return rc; }
void cs_disable_log(int8_t disabled) { if (cfg.disablelog != disabled) { if(disabled && logStarted) { cs_log("Stopping log..."); int32_t i = 0; while(ll_count(log_list) > 0 && i < 200){ cs_sleepms(5); ++i; } } cfg.disablelog = disabled; if (disabled){ if(logStarted) { cs_sleepms(20); cs_close_log(); } } else { cs_open_logfiles(); } } }
void cs_disable_log(int8_t disabled) { if(cfg.disablelog != disabled) { if(disabled && logStarted) { cs_log("Stopping log..."); log_list_flush(); } cfg.disablelog = disabled; if(disabled) { if(logStarted) { cs_sleepms(20); cs_close_log(); } } else { cs_open_logfiles(); } } }