* A list of output modules that will be active for the run mode.
*/
typedef struct RunModeOutput_ {
+ const char *name;
TmModule *tm_module;
OutputCtx *output_ctx;
TAILQ_INSERT_TAIL(&output_free_list, fl_output, entries);
}
+
+static int GetRunModeOutputPriority(RunModeOutput *module)
+{
+ TmModule *tm = TmModuleGetByName(module->name);
+ if (tm == NULL)
+ return 0;
+
+ return tm->priority;
+}
+
+static void InsertInRunModeOutputs(RunModeOutput *runmode_output)
+{
+ RunModeOutput *r_output = NULL;
+ int output_priority = GetRunModeOutputPriority(runmode_output);
+
+ TAILQ_FOREACH(r_output, &RunModeOutputs, entries) {
+ if (GetRunModeOutputPriority(r_output) < output_priority)
+ break;
+ }
+ if (r_output) {
+ TAILQ_INSERT_BEFORE(r_output, runmode_output, entries);
+ } else {
+ TAILQ_INSERT_TAIL(&RunModeOutputs, runmode_output, entries);
+ }
+}
+
/** \brief Turn output into thread module */
static void SetupOutput(const char *name, OutputModule *module, OutputCtx *output_ctx)
{
RunModeOutput *runmode_output = SCCalloc(1, sizeof(RunModeOutput));
if (unlikely(runmode_output == NULL))
return;
+ runmode_output->name = module->name;
runmode_output->tm_module = pkt_logger_module;
runmode_output->output_ctx = NULL;
- TAILQ_INSERT_TAIL(&RunModeOutputs, runmode_output, entries);
+ InsertInRunModeOutputs(runmode_output);
SCLogDebug("__packet_logger__ added");
}
} else if (module->TxLogFunc) {
RunModeOutput *runmode_output = SCCalloc(1, sizeof(RunModeOutput));
if (unlikely(runmode_output == NULL))
return;
+ runmode_output->name = module->name;
runmode_output->tm_module = tx_logger_module;
runmode_output->output_ctx = NULL;
- TAILQ_INSERT_TAIL(&RunModeOutputs, runmode_output, entries);
+ InsertInRunModeOutputs(runmode_output);
SCLogDebug("__tx_logger__ added");
}
} else if (module->FiledataLogFunc) {
RunModeOutput *runmode_output = SCCalloc(1, sizeof(RunModeOutput));
if (unlikely(runmode_output == NULL))
return;
+ runmode_output->name = module->name;
runmode_output->tm_module = filedata_logger_module;
runmode_output->output_ctx = NULL;
- TAILQ_INSERT_TAIL(&RunModeOutputs, runmode_output, entries);
+ InsertInRunModeOutputs(runmode_output);
SCLogDebug("__filedata_logger__ added");
}
} else if (module->FileLogFunc) {
RunModeOutput *runmode_output = SCCalloc(1, sizeof(RunModeOutput));
if (unlikely(runmode_output == NULL))
return;
+ runmode_output->name = module->name;
runmode_output->tm_module = file_logger_module;
runmode_output->output_ctx = NULL;
- TAILQ_INSERT_TAIL(&RunModeOutputs, runmode_output, entries);
+ InsertInRunModeOutputs(runmode_output);
SCLogDebug("__file_logger__ added");
}
} else if (module->StreamingLogFunc) {
RunModeOutput *runmode_output = SCCalloc(1, sizeof(RunModeOutput));
if (unlikely(runmode_output == NULL))
return;
+ runmode_output->name = module->name;
runmode_output->tm_module = streaming_logger_module;
runmode_output->output_ctx = NULL;
- TAILQ_INSERT_TAIL(&RunModeOutputs, runmode_output, entries);
+ InsertInRunModeOutputs(runmode_output);
SCLogDebug("__streaming_logger__ added");
}
} else {
RunModeOutput *runmode_output = SCCalloc(1, sizeof(RunModeOutput));
if (unlikely(runmode_output == NULL))
return;
+ runmode_output->name = module->name;
runmode_output->tm_module = tm_module;
runmode_output->output_ctx = output_ctx;
- TAILQ_INSERT_TAIL(&RunModeOutputs, runmode_output, entries);
+ InsertInRunModeOutputs(runmode_output);
}
}