<module_name>:<option_name>:<message_log_level>: <particular_message>
+The stdout logger also prints thread type and thread instance ID at the beginning
+of each trace message in a colon-separated manner.
+
+The capital letter at the beginning of the trace message indicates the thread type.
+
+Possible thread types:
+C – main (control) thread
+P – packet thread
+O – other thread
+
==== Example - Debugging rules using detection trace
The detection engine is responsible for rule evaluation. Turning on the
// Configure type affinity, but not the named thread affinity.
hwloc_bitmap_singlify(type_cpuset->cpuset);
- tc.set_thread_affinity(STHREAD_TYPE_OTHER, ThreadConfig::DEFAULT_THREAD_ID, type_cpuset);
+ tc.set_thread_affinity(STHREAD_TYPE_MAIN, ThreadConfig::DEFAULT_THREAD_ID, type_cpuset);
// The named thread should inherit the type affinity.
tc.implement_named_thread_affinity("not found, type other");
#include <cstdio>
#include <syslog.h>
+#include "main/thread.h"
+
using namespace snort;
//-----------------------------------------------
private:
FILE* file;
+ char thread_type;
+ unsigned instance_id;
};
StdoutTraceLogger::StdoutTraceLogger()
- : file(stdout)
-{ }
+ : file(stdout), instance_id(get_instance_id())
+{
+ auto t = get_thread_type();
+ switch (t)
+ {
+ case STHREAD_TYPE_PACKET:
+ thread_type = 'P';
+ break;
+ case STHREAD_TYPE_MAIN:
+ thread_type = 'C';
+ break;
+ default:
+ thread_type = 'O';
+ }
+}
void StdoutTraceLogger::log(const char* log_msg, const char* name,
uint8_t log_level, const char* trace_option, const Packet*)
{
- fprintf(file, "%s:%s:%d: %s", name, trace_option, log_level, log_msg);
+ fprintf(file, "%c%u:%s:%s:%d: %s", thread_type, instance_id, name,
+ trace_option, log_level, log_msg);
}
// Syslog