static int logging_start_wrapper(struct nafmodule *mod) { char *logfile; int newsyslog; if (initializing) return 0; #ifdef SUPPORTSYSLOG newsyslog = naf_config_getparmbool(CONFIG_PARM_USESYSLOG); if (newsyslog == -1) newsyslog = USESYSLOG_DEFAULT; #else newsyslog = 0; #endif logfile = naf_config_getmodparmstr(mod, "systemlogfile"); outstreamsyslog = newsyslog; if (!logfile && !outstreamsyslog) { /* Make sure at least one of these set. */ if (logging_start(mod, "-", &outfilename, &outstream) == -1) { fprintf(stderr, "could not initiate logging\n"); return -1; } } else { if (outstreamsyslog) { #ifdef SUPPORTSYSLOG openlog(naf_curappinfo.nai_name ? naf_curappinfo.nai_name : "naf", LOG_CONS | LOG_NDELAY | LOG_PID, LOG_USER); outstream = NULL; outfilename = NULL; #endif /* def SUPPORTSYSLOG */ } else { if (logfile && (logging_start(mod, logfile, &outfilename, &outstream) == -1)) { fprintf(stderr, "could not initiate logging\n"); return -1; } } } return 0; }
static void fileWriterTask(void *params) { LoggerMessage *msg = NULL; struct logging_status ls; memset(&ls, 0, sizeof(struct logging_status)); while(1) { int rc = -1; /* Get a sample. */ xQueueReceive(g_sampleRecordQueue, &(msg), portMAX_DELAY); switch (msg->type) { case LoggerMessageType_Sample: rc = logging_sample(&ls, msg); break; case LoggerMessageType_Start: rc = logging_start(&ls); break; case LoggerMessageType_Stop: rc = logging_stop(&ls); break; default: pr_warning("Unsupported message type\r\n"); } /* Turns the LED on if things are bad, off otherwise. */ error_led(rc); if (rc) { pr_debug("Msg type "); pr_debug_int(msg->type); pr_debug_int_msg(" failed with code ", rc); } flush_logfile(&ls); } }