diff --git a/src/DebugLogger.cc b/src/DebugLogger.cc index ab530d0840..6fe0ccc0bb 100644 --- a/src/DebugLogger.cc +++ b/src/DebugLogger.cc @@ -7,18 +7,28 @@ #include "Net.h" #include "plugin/Plugin.h" -DebugLogger debug_logger; +zeek::detail::DebugLogger zeek::detail::debug_logger; +zeek::detail::DebugLogger& debug_logger = zeek::detail::debug_logger; + +namespace zeek::detail { // Same order here as in DebugStream. DebugLogger::Stream DebugLogger::streams[NUM_DBGS] = { - { "serial", 0, false }, { "rules", 0, false }, + { "serial", 0, false }, + { "rules", 0, false }, { "string", 0, false }, - { "notifiers", 0, false }, { "main-loop", 0, false }, - { "dpd", 0, false }, { "tm", 0, false }, - { "logging", 0, false }, {"input", 0, false }, - { "threading", 0, false }, { "file_analysis", 0, false }, - { "plugins", 0, false }, { "zeekygen", 0, false }, - { "pktio", 0, false }, { "broker", 0, false }, + { "notifiers", 0, false }, + { "main-loop", 0, false }, + { "dpd", 0, false }, + { "tm", 0, false }, + { "logging", 0, false }, + {"input", 0, false }, + { "threading", 0, false }, + { "file_analysis", 0, false }, + { "plugins", 0, false }, + { "zeekygen", 0, false }, + { "pktio", 0, false }, + { "broker", 0, false }, { "scripts", 0, false}, { "supervisor", 0, false} }; @@ -183,4 +193,6 @@ void DebugLogger::Log(const zeek::plugin::Plugin& plugin, const char* fmt, ...) fflush(file); } +} // namespace zeek::detail + #endif diff --git a/src/DebugLogger.h b/src/DebugLogger.h index c0caa02088..7f63bb712e 100644 --- a/src/DebugLogger.h +++ b/src/DebugLogger.h @@ -9,6 +9,20 @@ #include #include +#define DBG_LOG(stream, args...) \ + if ( zeek::detail::debug_logger.IsEnabled(stream) ) \ + zeek::detail::debug_logger.Log(stream, args) +#define DBG_LOG_VERBOSE(stream, args...) \ + if ( zeek::detail::debug_logger.IsVerbose() && zeek::detail::debug_logger.IsEnabled(stream) ) \ + zeek::detail::debug_logger.Log(stream, args) +#define DBG_PUSH(stream) zeek::detail::debug_logger.PushIndent(stream) +#define DBG_POP(stream) zeek::detail::debug_logger.PopIndent(stream) + +#define PLUGIN_DBG_LOG(plugin, args...) zeek::detail::debug_logger.Log(plugin, args) + +namespace zeek { +namespace plugin { class Plugin; } + // To add a new debugging stream, add a constant here as well as // an entry to DebugLogger::streams in DebugLogger.cc. @@ -34,18 +48,7 @@ enum DebugStream { NUM_DBGS // Has to be last }; -#define DBG_LOG(stream, args...) \ - if ( debug_logger.IsEnabled(stream) ) \ - debug_logger.Log(stream, args) -#define DBG_LOG_VERBOSE(stream, args...) \ - if ( debug_logger.IsVerbose() && debug_logger.IsEnabled(stream) ) \ - debug_logger.Log(stream, args) -#define DBG_PUSH(stream) debug_logger.PushIndent(stream) -#define DBG_POP(stream) debug_logger.PopIndent(stream) - -#define PLUGIN_DBG_LOG(plugin, args...) debug_logger.Log(plugin, args) - -namespace zeek::plugin { class Plugin; } +namespace detail { class DebugLogger { public: @@ -96,6 +99,32 @@ private: extern DebugLogger debug_logger; +} // namespace detail +} // namespace zeek + +using DebugLogger [[deprecated("Remove in v4.1. Use zeek::detail::DebugLogger.")]] = zeek::detail::DebugLogger; + +using DebugStream [[deprecated("Remove in v4.1. Use zeek::DebugStream.")]] = zeek::DebugStream; +constexpr auto DBG_SERIAL [[deprecated("Remove in v4.1. Use zeek::DBG_SERIAL.")]] = zeek::DBG_SERIAL; +constexpr auto DBG_RULES [[deprecated("Remove in v4.1. Use zeek::DBG_RULES.")]] = zeek::DBG_RULES; +constexpr auto DBG_STRING [[deprecated("Remove in v4.1. Use zeek::DBG_STRING.")]] = zeek::DBG_STRING; +constexpr auto DBG_NOTIFIERS [[deprecated("Remove in v4.1. Use zeek::DBG_NOTIFIERS.")]] = zeek::DBG_NOTIFIERS; +constexpr auto DBG_MAINLOOP [[deprecated("Remove in v4.1. Use zeek::DBG_MAINLOOP.")]] = zeek::DBG_MAINLOOP; +constexpr auto DBG_ANALYZER [[deprecated("Remove in v4.1. Use zeek::DBG_ANALYZER.")]] = zeek::DBG_ANALYZER; +constexpr auto DBG_TM [[deprecated("Remove in v4.1. Use zeek::DBG_TM.")]] = zeek::DBG_TM; +constexpr auto DBG_LOGGING [[deprecated("Remove in v4.1. Use zeek::DBG_LOGGING.")]] = zeek::DBG_LOGGING; +constexpr auto DBG_INPUT [[deprecated("Remove in v4.1. Use zeek::DBG_INPUT.")]] = zeek::DBG_INPUT; +constexpr auto DBG_THREADING [[deprecated("Remove in v4.1. Use zeek::DBG_THREADING.")]] = zeek::DBG_THREADING; +constexpr auto DBG_FILE_ANALYSIS [[deprecated("Remove in v4.1. Use zeek::DBG_FILE_ANALYSIS.")]] = zeek::DBG_FILE_ANALYSIS; +constexpr auto DBG_PLUGINS [[deprecated("Remove in v4.1. Use zeek::DBG_PLUGINS.")]] = zeek::DBG_PLUGINS; +constexpr auto DBG_ZEEKYGEN [[deprecated("Remove in v4.1. Use zeek::DBG_ZEEKYGEN.")]] = zeek::DBG_ZEEKYGEN; +constexpr auto DBG_PKTIO [[deprecated("Remove in v4.1. Use zeek::DBG_PKTIO.")]] = zeek::DBG_PKTIO; +constexpr auto DBG_BROKER [[deprecated("Remove in v4.1. Use zeek::DBG_BROKER.")]] = zeek::DBG_BROKER; +constexpr auto DBG_SCRIPTS [[deprecated("Remove in v4.1. Use zeek::DBG_SCRIPTS.")]] = zeek::DBG_SCRIPTS; +constexpr auto DBG_SUPERVISOR [[deprecated("Remove in v4.1. Use zeek::DBG_SUPERVISOR.")]] = zeek::DBG_SUPERVISOR; + +extern zeek::detail::DebugLogger& debug_logger; + #else #define DBG_LOG(args...) #define DBG_LOG_VERBOSE(args...) diff --git a/src/Expr.cc b/src/Expr.cc index a628eb0623..edf5de7f29 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -4154,7 +4154,7 @@ ValPtr CallExpr::Eval(Frame* f) const { if ( Val* v = trigger->Lookup(this) ) { - DBG_LOG(DBG_NOTIFIERS, + DBG_LOG(zeek::DBG_NOTIFIERS, "%s: provides cached function result", trigger->Name()); return {zeek::NewRef{}, v}; diff --git a/src/Net.cc b/src/Net.cc index 39b0387d01..7ae10f834c 100644 --- a/src/Net.cc +++ b/src/Net.cc @@ -293,7 +293,7 @@ void net_run() // starting with the first. if ( ! ready.empty() || loop_counter++ % 100 == 0 ) { - DBG_LOG(DBG_MAINLOOP, "realtime=%.6f ready_count=%zu", + DBG_LOG(zeek::DBG_MAINLOOP, "realtime=%.6f ready_count=%zu", current_time(), ready.size()); if ( ! ready.empty() ) @@ -307,7 +307,7 @@ void net_run() { for ( auto src : ready ) { - DBG_LOG(DBG_MAINLOOP, "processing source %s", src->Tag()); + DBG_LOG(zeek::DBG_MAINLOOP, "processing source %s", src->Tag()); current_iosrc = src; src->Process(); } diff --git a/src/Notifier.cc b/src/Notifier.cc index 0acd7e6cec..5200de282b 100644 --- a/src/Notifier.cc +++ b/src/Notifier.cc @@ -9,12 +9,12 @@ notifier::Registry notifier::registry; notifier::Receiver::Receiver() { - DBG_LOG(DBG_NOTIFIERS, "creating receiver %p", this); + DBG_LOG(zeek::DBG_NOTIFIERS, "creating receiver %p", this); } notifier::Receiver::~Receiver() { - DBG_LOG(DBG_NOTIFIERS, "deleting receiver %p", this); + DBG_LOG(zeek::DBG_NOTIFIERS, "deleting receiver %p", this); } notifier::Registry::~Registry() @@ -25,7 +25,7 @@ notifier::Registry::~Registry() void notifier::Registry::Register(Modifiable* m, notifier::Receiver* r) { - DBG_LOG(DBG_NOTIFIERS, "registering object %p for receiver %p", m, r); + DBG_LOG(zeek::DBG_NOTIFIERS, "registering object %p for receiver %p", m, r); registrations.insert({m, r}); ++m->num_receivers; @@ -33,7 +33,7 @@ void notifier::Registry::Register(Modifiable* m, notifier::Receiver* r) void notifier::Registry::Unregister(Modifiable* m, notifier::Receiver* r) { - DBG_LOG(DBG_NOTIFIERS, "unregistering object %p from receiver %p", m, r); + DBG_LOG(zeek::DBG_NOTIFIERS, "unregistering object %p from receiver %p", m, r); auto x = registrations.equal_range(m); for ( auto i = x.first; i != x.second; i++ ) @@ -49,7 +49,7 @@ void notifier::Registry::Unregister(Modifiable* m, notifier::Receiver* r) void notifier::Registry::Unregister(Modifiable* m) { - DBG_LOG(DBG_NOTIFIERS, "unregistering object %p from all notifiers", m); + DBG_LOG(zeek::DBG_NOTIFIERS, "unregistering object %p from all notifiers", m); auto x = registrations.equal_range(m); for ( auto i = x.first; i != x.second; i++ ) @@ -60,7 +60,7 @@ void notifier::Registry::Unregister(Modifiable* m) void notifier::Registry::Modified(Modifiable* m) { - DBG_LOG(DBG_NOTIFIERS, "object %p has been modified", m); + DBG_LOG(zeek::DBG_NOTIFIERS, "object %p has been modified", m); auto x = registrations.equal_range(m); for ( auto i = x.first; i != x.second; i++ ) diff --git a/src/RuleMatcher.cc b/src/RuleMatcher.cc index 413b8bd8a1..8b726c5b6a 100644 --- a/src/RuleMatcher.cc +++ b/src/RuleMatcher.cc @@ -637,7 +637,7 @@ RuleFileMagicState* RuleMatcher::InitFileMagic() const bool RuleMatcher::AllRulePatternsMatched(const Rule* r, MatchPos matchpos, const AcceptingMatchSet& ams) { - DBG_LOG(DBG_RULES, "Checking rule: %s", r->id); + DBG_LOG(zeek::DBG_RULES, "Checking rule: %s", r->id); // Check whether all patterns of the rule have matched. for ( const auto& pattern : r->patterns ) @@ -652,7 +652,7 @@ bool RuleMatcher::AllRulePatternsMatched(const Rule* r, MatchPos matchpos, // FIXME: How to check for offset ??? ### } - DBG_LOG(DBG_RULES, "All patterns of rule satisfied"); + DBG_LOG(zeek::DBG_RULES, "All patterns of rule satisfied"); return true; } @@ -671,11 +671,11 @@ RuleMatcher::MIME_Matches* RuleMatcher::Match(RuleFileMagicState* state, } #ifdef DEBUG - if ( debug_logger.IsEnabled(DBG_RULES) ) + if ( debug_logger.IsEnabled(zeek::DBG_RULES) ) { const char* s = fmt_bytes(reinterpret_cast(data), min(40, static_cast(len))); - DBG_LOG(DBG_RULES, "Matching %s rules on |%s%s|", + DBG_LOG(zeek::DBG_RULES, "Matching %s rules on |%s%s|", Rule::TypeToString(Rule::FILE_MAGIC), s, len > 40 ? "..." : ""); } @@ -692,7 +692,7 @@ RuleMatcher::MIME_Matches* RuleMatcher::Match(RuleFileMagicState* state, if ( ! newmatch ) return rval; - DBG_LOG(DBG_RULES, "New pattern match found"); + DBG_LOG(zeek::DBG_RULES, "New pattern match found"); AcceptingMatchSet accepted_matches; @@ -753,7 +753,7 @@ RuleEndpointState* RuleMatcher::InitEndpoint(zeek::analyzer::Analyzer* analyzer, { RuleHdrTest* hdr_test = tests[h]; - DBG_LOG(DBG_RULES, "HdrTest %d matches (%s%s)", hdr_test->id, + DBG_LOG(zeek::DBG_RULES, "HdrTest %d matches (%s%s)", hdr_test->id, hdr_test->pattern_rules ? "+" : "-", hdr_test->pure_rules ? "+" : "-"); @@ -868,12 +868,12 @@ void RuleMatcher::Match(RuleEndpointState* state, Rule::PatternType type, bool newmatch = false; #ifdef DEBUG - if ( debug_logger.IsEnabled(DBG_RULES) ) + if ( debug_logger.IsEnabled(zeek::DBG_RULES) ) { const char* s = fmt_bytes((const char *) data, min(40, data_len)); - DBG_LOG(DBG_RULES, "Matching %s rules [%d,%d] on |%s%s|", + DBG_LOG(zeek::DBG_RULES, "Matching %s rules [%d,%d] on |%s%s|", Rule::TypeToString(type), bol, eol, s, data_len > 40 ? "..." : ""); } @@ -904,7 +904,7 @@ void RuleMatcher::Match(RuleEndpointState* state, Rule::PatternType type, if ( ! newmatch ) return; - DBG_LOG(DBG_RULES, "New pattern match found"); + DBG_LOG(zeek::DBG_RULES, "New pattern match found"); AcceptingMatchSet accepted_matches; @@ -940,17 +940,17 @@ void RuleMatcher::Match(RuleEndpointState* state, Rule::PatternType type, { Rule* r = *it; - DBG_LOG(DBG_RULES, "Accepted rule: %s", r->id); + DBG_LOG(zeek::DBG_RULES, "Accepted rule: %s", r->id); for ( const auto& h : state->hdr_tests ) { - DBG_LOG(DBG_RULES, "Checking for accepted rule on HdrTest %d", h->id); + DBG_LOG(zeek::DBG_RULES, "Checking for accepted rule on HdrTest %d", h->id); // Skip if rule does not belong to this node. if ( ! h->ruleset->Contains(r->Index()) ) continue; - DBG_LOG(DBG_RULES, "On current node"); + DBG_LOG(zeek::DBG_RULES, "On current node"); // Skip if rule already fired for this connection. if ( is_member_of(state->matched_rules, r->Index()) ) @@ -964,7 +964,7 @@ void RuleMatcher::Match(RuleEndpointState* state, Rule::PatternType type, state->matched_text.push_back(s); } - DBG_LOG(DBG_RULES, "And has not already fired"); + DBG_LOG(zeek::DBG_RULES, "And has not already fired"); // Eval additional conditions. if ( ! EvalRuleConditions(r, state, data, data_len, false) ) continue; @@ -1006,11 +1006,11 @@ bool RuleMatcher::ExecRulePurely(Rule* r, zeek::String* s, if ( is_member_of(state->matched_rules, r->Index()) ) return false; - DBG_LOG(DBG_RULES, "Checking rule %s purely", r->ID()); + DBG_LOG(zeek::DBG_RULES, "Checking rule %s purely", r->ID()); if ( EvalRuleConditions(r, state, nullptr, 0, eos) ) { - DBG_LOG(DBG_RULES, "MATCH!"); + DBG_LOG(zeek::DBG_RULES, "MATCH!"); if ( s ) ExecRuleActions(r, state, s->Bytes(), s->Len(), eos); @@ -1026,7 +1026,7 @@ bool RuleMatcher::ExecRulePurely(Rule* r, zeek::String* s, bool RuleMatcher::EvalRuleConditions(Rule* r, RuleEndpointState* state, const u_char* data, int len, bool eos) { - DBG_LOG(DBG_RULES, "Evaluating conditions for rule %s", r->ID()); + DBG_LOG(zeek::DBG_RULES, "Evaluating conditions for rule %s", r->ID()); // Check for other rules which have to match first. for ( const auto& pc : r->preconds ) @@ -1063,7 +1063,7 @@ bool RuleMatcher::EvalRuleConditions(Rule* r, RuleEndpointState* state, if ( ! cond->DoMatch(r, state, data, len) ) return false; - DBG_LOG(DBG_RULES, "Conditions met: MATCH! %s", r->ID()); + DBG_LOG(zeek::DBG_RULES, "Conditions met: MATCH! %s", r->ID()); return true; } diff --git a/src/SerializationFormat.cc b/src/SerializationFormat.cc index e5a7f26f6b..c60a3edc39 100644 --- a/src/SerializationFormat.cc +++ b/src/SerializationFormat.cc @@ -107,7 +107,7 @@ bool BinarySerializationFormat::Read(int* v, const char* tag) return false; *v = (int) ntohl(tmp); - DBG_LOG(DBG_SERIAL, "Read int %d [%s]", *v, tag); + DBG_LOG(zeek::DBG_SERIAL, "Read int %d [%s]", *v, tag); return true; } @@ -117,7 +117,7 @@ bool BinarySerializationFormat::Read(uint16_t* v, const char* tag) return false; *v = ntohs(*v); - DBG_LOG(DBG_SERIAL, "Read uint16_t %hu [%s]", *v, tag); + DBG_LOG(zeek::DBG_SERIAL, "Read uint16_t %hu [%s]", *v, tag); return true; } @@ -127,7 +127,7 @@ bool BinarySerializationFormat::Read(uint32_t* v, const char* tag) return false; *v = ntohl(*v); - DBG_LOG(DBG_SERIAL, "Read uint32_t %" PRIu32 " [%s]", *v, tag); + DBG_LOG(zeek::DBG_SERIAL, "Read uint32_t %" PRIu32 " [%s]", *v, tag); return true; } @@ -139,7 +139,7 @@ bool BinarySerializationFormat::Read(int64_t* v, const char* tag) return false; *v = ((int64_t(ntohl(x[0]))) << 32) | ntohl(x[1]); - DBG_LOG(DBG_SERIAL, "Read int64_t %" PRId64 " [%s]", *v, tag); + DBG_LOG(zeek::DBG_SERIAL, "Read int64_t %" PRId64 " [%s]", *v, tag); return true; } @@ -150,7 +150,7 @@ bool BinarySerializationFormat::Read(uint64_t* v, const char* tag) return false; *v = ((uint64_t(ntohl(x[0]))) << 32) | ntohl(x[1]); - DBG_LOG(DBG_SERIAL, "Read uint64_t %" PRIu64 " [%s]", *v, tag); + DBG_LOG(zeek::DBG_SERIAL, "Read uint64_t %" PRIu64 " [%s]", *v, tag); return true; } @@ -161,7 +161,7 @@ bool BinarySerializationFormat::Read(bool* v, const char* tag) return false; *v = c == '\1' ? true : false; - DBG_LOG(DBG_SERIAL, "Read bool %s [%s]", *v ? "true" : "false", tag); + DBG_LOG(zeek::DBG_SERIAL, "Read bool %s [%s]", *v ? "true" : "false", tag); return true; } @@ -171,14 +171,14 @@ bool BinarySerializationFormat::Read(double* d, const char* tag) return false; *d = ntohd(*d); - DBG_LOG(DBG_SERIAL, "Read double %.6f [%s]", *d, tag); + DBG_LOG(zeek::DBG_SERIAL, "Read double %.6f [%s]", *d, tag); return true; } bool BinarySerializationFormat::Read(char* v, const char* tag) { bool ret = ReadData(v, 1); - DBG_LOG(DBG_SERIAL, "Read char %s [%s]", fmt_bytes(v, 1), tag); + DBG_LOG(zeek::DBG_SERIAL, "Read char %s [%s]", fmt_bytes(v, 1), tag); return ret; } @@ -216,7 +216,7 @@ bool BinarySerializationFormat::Read(char** str, int* len, const char* tag) *str = s; - DBG_LOG(DBG_SERIAL, "Read %d bytes |%s| [%s]", l, fmt_bytes(*str, l), tag); + DBG_LOG(zeek::DBG_SERIAL, "Read %d bytes |%s| [%s]", l, fmt_bytes(*str, l), tag); return true; } @@ -301,34 +301,34 @@ bool BinarySerializationFormat::Read(struct in6_addr* addr, const char* tag) bool BinarySerializationFormat::Write(char v, const char* tag) { - DBG_LOG(DBG_SERIAL, "Write char %s [%s]", fmt_bytes(&v, 1), tag); + DBG_LOG(zeek::DBG_SERIAL, "Write char %s [%s]", fmt_bytes(&v, 1), tag); return WriteData(&v, 1); } bool BinarySerializationFormat::Write(uint16_t v, const char* tag) { - DBG_LOG(DBG_SERIAL, "Write uint16_t %hu [%s]", v, tag); + DBG_LOG(zeek::DBG_SERIAL, "Write uint16_t %hu [%s]", v, tag); v = htons(v); return WriteData(&v, sizeof(v)); } bool BinarySerializationFormat::Write(uint32_t v, const char* tag) { - DBG_LOG(DBG_SERIAL, "Write uint32_t %" PRIu32 " [%s]", v, tag); + DBG_LOG(zeek::DBG_SERIAL, "Write uint32_t %" PRIu32 " [%s]", v, tag); v = htonl(v); return WriteData(&v, sizeof(v)); } bool BinarySerializationFormat::Write(int v, const char* tag) { - DBG_LOG(DBG_SERIAL, "Write int %d [%s]", v, tag); + DBG_LOG(zeek::DBG_SERIAL, "Write int %d [%s]", v, tag); uint32_t tmp = htonl((uint32_t) v); return WriteData(&tmp, sizeof(tmp)); } bool BinarySerializationFormat::Write(uint64_t v, const char* tag) { - DBG_LOG(DBG_SERIAL, "Write uint64_t %" PRIu64 " [%s]", v, tag); + DBG_LOG(zeek::DBG_SERIAL, "Write uint64_t %" PRIu64 " [%s]", v, tag); uint32_t x[2]; x[0] = htonl(v >> 32); x[1] = htonl(v & 0xffffffff); @@ -337,7 +337,7 @@ bool BinarySerializationFormat::Write(uint64_t v, const char* tag) bool BinarySerializationFormat::Write(int64_t v, const char* tag) { - DBG_LOG(DBG_SERIAL, "Write int64_t %" PRId64 " [%s]", v, tag); + DBG_LOG(zeek::DBG_SERIAL, "Write int64_t %" PRId64 " [%s]", v, tag); uint32_t x[2]; x[0] = htonl(v >> 32); x[1] = htonl(v & 0xffffffff); @@ -346,14 +346,14 @@ bool BinarySerializationFormat::Write(int64_t v, const char* tag) bool BinarySerializationFormat::Write(double d, const char* tag) { - DBG_LOG(DBG_SERIAL, "Write double %.6f [%s]", d, tag); + DBG_LOG(zeek::DBG_SERIAL, "Write double %.6f [%s]", d, tag); d = htond(d); return WriteData(&d, sizeof(d)); } bool BinarySerializationFormat::Write(bool v, const char* tag) { - DBG_LOG(DBG_SERIAL, "Write bool %s [%s]", v ? "true" : "false", tag); + DBG_LOG(zeek::DBG_SERIAL, "Write bool %s [%s]", v ? "true" : "false", tag); char c = v ? '\1' : '\0'; return WriteData(&c, 1); } @@ -432,7 +432,7 @@ bool BinarySerializationFormat::WriteSeparator() bool BinarySerializationFormat::Write(const char* buf, int len, const char* tag) { - DBG_LOG(DBG_SERIAL, "Write bytes |%s| [%s]", fmt_bytes(buf, len), tag); + DBG_LOG(zeek::DBG_SERIAL, "Write bytes |%s| [%s]", fmt_bytes(buf, len), tag); uint32_t l = htonl(len); return WriteData(&l, sizeof(l)) && WriteData(buf, len); } diff --git a/src/Timer.cc b/src/Timer.cc index cd3933cf40..0bca3ff670 100644 --- a/src/Timer.cc +++ b/src/Timer.cc @@ -79,7 +79,7 @@ TimerMgr::~TimerMgr() int TimerMgr::Advance(double arg_t, int max_expire) { - DBG_LOG(DBG_TM, "advancing timer mgr to %.6f", arg_t); + DBG_LOG(zeek::DBG_TM, "advancing timer mgr to %.6f", arg_t); t = arg_t; last_timestamp = 0; @@ -122,7 +122,7 @@ PQ_TimerMgr::~PQ_TimerMgr() void PQ_TimerMgr::Add(Timer* timer) { - DBG_LOG(DBG_TM, "Adding timer %s (%p) at %.6f", + DBG_LOG(zeek::DBG_TM, "Adding timer %s (%p) at %.6f", timer_type_to_string(timer->Type()), timer, timer->Time()); // Add the timer even if it's already expired - that way, if @@ -139,7 +139,7 @@ void PQ_TimerMgr::Expire() Timer* timer; while ( (timer = Remove()) ) { - DBG_LOG(DBG_TM, "Dispatching timer %s (%p)", + DBG_LOG(zeek::DBG_TM, "Dispatching timer %s (%p)", timer_type_to_string(timer->Type()), timer); timer->Dispatch(t, true); --current_timers[timer->Type()]; @@ -161,7 +161,7 @@ int PQ_TimerMgr::DoAdvance(double new_t, int max_expire) // whether we should delete it too. (void) Remove(); - DBG_LOG(DBG_TM, "Dispatching timer %s (%p)", + DBG_LOG(zeek::DBG_TM, "Dispatching timer %s (%p)", timer_type_to_string(timer->Type()), timer); timer->Dispatch(new_t, false); delete timer; diff --git a/src/Trigger.cc b/src/Trigger.cc index c8a80b0293..8998239c0b 100644 --- a/src/Trigger.cc +++ b/src/Trigger.cc @@ -135,7 +135,7 @@ Trigger::Trigger(zeek::detail::Expr* arg_cond, zeek::detail::Stmt* arg_body, location = arg_location; timeout_value = -1; - DBG_LOG(DBG_NOTIFIERS, "%s: instantiating", Name()); + DBG_LOG(zeek::DBG_NOTIFIERS, "%s: instantiating", Name()); if ( is_return ) { @@ -204,7 +204,7 @@ void Trigger::Terminate() Trigger::~Trigger() { - DBG_LOG(DBG_NOTIFIERS, "%s: deleting", Name()); + DBG_LOG(zeek::DBG_NOTIFIERS, "%s: deleting", Name()); for ( ValCache::iterator i = cache.begin(); i != cache.end(); ++i ) Unref(i->second); @@ -230,11 +230,11 @@ bool Trigger::Eval() if ( disabled ) return true; - DBG_LOG(DBG_NOTIFIERS, "%s: evaluating", Name()); + DBG_LOG(zeek::DBG_NOTIFIERS, "%s: evaluating", Name()); if ( delayed ) { - DBG_LOG(DBG_NOTIFIERS, "%s: skipping eval due to delayed call", + DBG_LOG(zeek::DBG_NOTIFIERS, "%s: skipping eval due to delayed call", Name()); return false; } @@ -277,7 +277,7 @@ bool Trigger::Eval() if ( f->HasDelayed() ) { - DBG_LOG(DBG_NOTIFIERS, "%s: eval has delayed", Name()); + DBG_LOG(zeek::DBG_NOTIFIERS, "%s: eval has delayed", Name()); assert(!v); Unref(f); return false; @@ -286,13 +286,13 @@ bool Trigger::Eval() if ( ! v || v->IsZero() ) { // Not true. Perhaps next time... - DBG_LOG(DBG_NOTIFIERS, "%s: trigger condition is false", Name()); + DBG_LOG(zeek::DBG_NOTIFIERS, "%s: trigger condition is false", Name()); Unref(f); Init(); return false; } - DBG_LOG(DBG_NOTIFIERS, "%s: trigger condition is true, executing", + DBG_LOG(zeek::DBG_NOTIFIERS, "%s: trigger condition is true, executing", Name()); v = nullptr; @@ -314,7 +314,7 @@ bool Trigger::Eval() #ifdef DEBUG const char* pname = copy_string(trigger->Name()); - DBG_LOG(DBG_NOTIFIERS, "%s: trigger has parent %s, caching result", Name(), pname); + DBG_LOG(zeek::DBG_NOTIFIERS, "%s: trigger has parent %s, caching result", Name(), pname); delete [] pname; #endif @@ -344,7 +344,7 @@ void Trigger::Timeout() if ( disabled ) return; - DBG_LOG(DBG_NOTIFIERS, "%s: timeout", Name()); + DBG_LOG(zeek::DBG_NOTIFIERS, "%s: timeout", Name()); if ( timeout_stmts ) { stmt_flow_type flow; @@ -367,7 +367,7 @@ void Trigger::Timeout() #ifdef DEBUG const char* pname = copy_string(trigger->Name()); - DBG_LOG(DBG_NOTIFIERS, "%s: trigger has parent %s, caching timeout result", Name(), pname); + DBG_LOG(zeek::DBG_NOTIFIERS, "%s: trigger has parent %s, caching timeout result", Name(), pname); delete [] pname; #endif auto queued = trigger->Cache(frame->GetCall(), v.get()); @@ -408,7 +408,7 @@ void Trigger::Register(Val* val) void Trigger::UnregisterAll() { - DBG_LOG(DBG_NOTIFIERS, "%s: unregistering all", Name()); + DBG_LOG(zeek::DBG_NOTIFIERS, "%s: unregistering all", Name()); for ( const auto& o : objs ) { @@ -427,7 +427,7 @@ void Trigger::Attach(Trigger *trigger) #ifdef DEBUG const char* pname = copy_string(trigger->Name()); - DBG_LOG(DBG_NOTIFIERS, "%s: attaching to %s", Name(), pname); + DBG_LOG(zeek::DBG_NOTIFIERS, "%s: attaching to %s", Name(), pname); delete [] pname; #endif @@ -510,7 +510,7 @@ double Manager::GetNextTimeout() void Manager::Process() { - DBG_LOG(DBG_NOTIFIERS, "evaluating all pending triggers"); + DBG_LOG(zeek::DBG_NOTIFIERS, "evaluating all pending triggers"); // While we iterate over the list, executing statements, we may // in fact trigger new triggers and thereby modify the list. diff --git a/src/ZeekString.cc b/src/ZeekString.cc index 6e50be9ab4..b261b4d626 100644 --- a/src/ZeekString.cc +++ b/src/ZeekString.cc @@ -13,7 +13,7 @@ #include "util.h" #ifdef DEBUG -#define DEBUG_STR(msg) DBG_LOG(DBG_STRING, msg) +#define DEBUG_STR(msg) DBG_LOG(zeek::DBG_STRING, msg) #else #define DEBUG_STR(msg) #endif diff --git a/src/analyzer/Analyzer.cc b/src/analyzer/Analyzer.cc index 1cd6a87316..b24dc88ae4 100644 --- a/src/analyzer/Analyzer.cc +++ b/src/analyzer/Analyzer.cc @@ -413,7 +413,7 @@ bool Analyzer::AddChildAnalyzer(Analyzer* analyzer, bool init) if ( init ) analyzer->Init(); - DBG_LOG(DBG_ANALYZER, "%s added child %s", + DBG_LOG(zeek::DBG_ANALYZER, "%s added child %s", fmt_analyzer(this).c_str(), fmt_analyzer(analyzer).c_str()); return true; } @@ -446,7 +446,7 @@ bool Analyzer::RemoveChild(const analyzer_list& children, ID id) if ( i->finished || i->removing ) return false; - DBG_LOG(DBG_ANALYZER, "%s disabling child %s", + DBG_LOG(zeek::DBG_ANALYZER, "%s disabling child %s", fmt_analyzer(this).c_str(), fmt_analyzer(i).c_str()); // We just flag it as being removed here but postpone // actually doing that to later. Otherwise, we'd need @@ -559,7 +559,7 @@ void Analyzer::DeleteChild(analyzer_list::iterator i) child->removing = false; } - DBG_LOG(DBG_ANALYZER, "%s deleted child %s 3", + DBG_LOG(zeek::DBG_ANALYZER, "%s deleted child %s 3", fmt_analyzer(this).c_str(), fmt_analyzer(child).c_str()); children.erase(i); @@ -570,7 +570,7 @@ void Analyzer::AddSupportAnalyzer(SupportAnalyzer* analyzer) { if ( HasSupportAnalyzer(analyzer->GetAnalyzerTag(), analyzer->IsOrig()) ) { - DBG_LOG(DBG_ANALYZER, "%s already has %s %s", + DBG_LOG(zeek::DBG_ANALYZER, "%s already has %s %s", fmt_analyzer(this).c_str(), analyzer->IsOrig() ? "originator" : "responder", fmt_analyzer(analyzer).c_str()); @@ -598,7 +598,7 @@ void Analyzer::AddSupportAnalyzer(SupportAnalyzer* analyzer) analyzer->Init(); - DBG_LOG(DBG_ANALYZER, "%s added %s support %s", + DBG_LOG(zeek::DBG_ANALYZER, "%s added %s support %s", fmt_analyzer(this).c_str(), analyzer->IsOrig() ? "originator" : "responder", fmt_analyzer(analyzer).c_str()); @@ -606,7 +606,7 @@ void Analyzer::AddSupportAnalyzer(SupportAnalyzer* analyzer) void Analyzer::RemoveSupportAnalyzer(SupportAnalyzer* analyzer) { - DBG_LOG(DBG_ANALYZER, "%s disabled %s support analyzer %s", + DBG_LOG(zeek::DBG_ANALYZER, "%s disabled %s support analyzer %s", fmt_analyzer(this).c_str(), analyzer->IsOrig() ? "originator" : "responder", fmt_analyzer(analyzer).c_str()); @@ -646,33 +646,33 @@ SupportAnalyzer* Analyzer::FirstSupportAnalyzer(bool orig) void Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig, uint64_t seq, const zeek::IP_Hdr* ip, int caplen) { - DBG_LOG(DBG_ANALYZER, "%s DeliverPacket(%d, %s, %" PRIu64", %p, %d) [%s%s]", + DBG_LOG(zeek::DBG_ANALYZER, "%s DeliverPacket(%d, %s, %" PRIu64", %p, %d) [%s%s]", fmt_analyzer(this).c_str(), len, is_orig ? "T" : "F", seq, ip, caplen, fmt_bytes((const char*) data, min(40, len)), len > 40 ? "..." : ""); } void Analyzer::DeliverStream(int len, const u_char* data, bool is_orig) { - DBG_LOG(DBG_ANALYZER, "%s DeliverStream(%d, %s) [%s%s]", + DBG_LOG(zeek::DBG_ANALYZER, "%s DeliverStream(%d, %s) [%s%s]", fmt_analyzer(this).c_str(), len, is_orig ? "T" : "F", fmt_bytes((const char*) data, min(40, len)), len > 40 ? "..." : ""); } void Analyzer::Undelivered(uint64_t seq, int len, bool is_orig) { - DBG_LOG(DBG_ANALYZER, "%s Undelivered(%" PRIu64", %d, %s)", + DBG_LOG(zeek::DBG_ANALYZER, "%s Undelivered(%" PRIu64", %d, %s)", fmt_analyzer(this).c_str(), seq, len, is_orig ? "T" : "F"); } void Analyzer::EndOfData(bool is_orig) { - DBG_LOG(DBG_ANALYZER, "%s EndOfData(%s)", + DBG_LOG(zeek::DBG_ANALYZER, "%s EndOfData(%s)", fmt_analyzer(this).c_str(), is_orig ? "T" : "F"); } void Analyzer::FlipRoles() { - DBG_LOG(DBG_ANALYZER, "%s FlipRoles()", fmt_analyzer(this).c_str()); + DBG_LOG(zeek::DBG_ANALYZER, "%s FlipRoles()", fmt_analyzer(this).c_str()); LOOP_OVER_CHILDREN(i) (*i)->FlipRoles(); diff --git a/src/analyzer/Manager.cc b/src/analyzer/Manager.cc index 2c92936b74..75bb28d1db 100644 --- a/src/analyzer/Manager.cc +++ b/src/analyzer/Manager.cc @@ -105,14 +105,14 @@ void Manager::InitPostScript() void Manager::DumpDebug() { #ifdef DEBUG - DBG_LOG(DBG_ANALYZER, "Available analyzers after zeek_init():"); + DBG_LOG(zeek::DBG_ANALYZER, "Available analyzers after zeek_init():"); std::list all_analyzers = GetComponents(); for ( std::list::const_iterator i = all_analyzers.begin(); i != all_analyzers.end(); ++i ) - DBG_LOG(DBG_ANALYZER, " %s (%s)", (*i)->Name().c_str(), + DBG_LOG(zeek::DBG_ANALYZER, " %s (%s)", (*i)->Name().c_str(), IsEnabled((*i)->Tag()) ? "enabled" : "disabled"); - DBG_LOG(DBG_ANALYZER, " "); - DBG_LOG(DBG_ANALYZER, "Analyzers by port:"); + DBG_LOG(zeek::DBG_ANALYZER, " "); + DBG_LOG(zeek::DBG_ANALYZER, "Analyzers by port:"); for ( analyzer_map_by_port::const_iterator i = analyzers_by_port_tcp.begin(); i != analyzers_by_port_tcp.end(); i++ ) { @@ -121,7 +121,7 @@ void Manager::DumpDebug() for ( tag_set::const_iterator j = i->second->begin(); j != i->second->end(); j++ ) s += std::string(GetComponentName(*j)) + " "; - DBG_LOG(DBG_ANALYZER, " %d/tcp: %s", i->first, s.c_str()); + DBG_LOG(zeek::DBG_ANALYZER, " %d/tcp: %s", i->first, s.c_str()); } for ( analyzer_map_by_port::const_iterator i = analyzers_by_port_udp.begin(); i != analyzers_by_port_udp.end(); i++ ) @@ -131,7 +131,7 @@ void Manager::DumpDebug() for ( tag_set::const_iterator j = i->second->begin(); j != i->second->end(); j++ ) s += std::string(GetComponentName(*j)) + " "; - DBG_LOG(DBG_ANALYZER, " %d/udp: %s", i->first, s.c_str()); + DBG_LOG(zeek::DBG_ANALYZER, " %d/udp: %s", i->first, s.c_str()); } #endif @@ -148,7 +148,7 @@ bool Manager::EnableAnalyzer(const Tag& tag) if ( ! p ) return false; - DBG_LOG(DBG_ANALYZER, "Enabling analyzer %s", p->Name().c_str()); + DBG_LOG(zeek::DBG_ANALYZER, "Enabling analyzer %s", p->Name().c_str()); p->SetEnabled(true); return true; @@ -161,7 +161,7 @@ bool Manager::EnableAnalyzer(zeek::EnumVal* val) if ( ! p ) return false; - DBG_LOG(DBG_ANALYZER, "Enabling analyzer %s", p->Name().c_str()); + DBG_LOG(zeek::DBG_ANALYZER, "Enabling analyzer %s", p->Name().c_str()); p->SetEnabled(true); return true; @@ -174,7 +174,7 @@ bool Manager::DisableAnalyzer(const Tag& tag) if ( ! p ) return false; - DBG_LOG(DBG_ANALYZER, "Disabling analyzer %s", p->Name().c_str()); + DBG_LOG(zeek::DBG_ANALYZER, "Disabling analyzer %s", p->Name().c_str()); p->SetEnabled(false); return true; @@ -187,7 +187,7 @@ bool Manager::DisableAnalyzer(zeek::EnumVal* val) if ( ! p ) return false; - DBG_LOG(DBG_ANALYZER, "Disabling analyzer %s", p->Name().c_str()); + DBG_LOG(zeek::DBG_ANALYZER, "Disabling analyzer %s", p->Name().c_str()); p->SetEnabled(false); return true; @@ -195,7 +195,7 @@ bool Manager::DisableAnalyzer(zeek::EnumVal* val) void Manager::DisableAllAnalyzers() { - DBG_LOG(DBG_ANALYZER, "Disabling all analyzers"); + DBG_LOG(zeek::DBG_ANALYZER, "Disabling all analyzers"); std::list all_analyzers = GetComponents(); for ( std::list::const_iterator i = all_analyzers.begin(); i != all_analyzers.end(); ++i ) @@ -260,7 +260,7 @@ bool Manager::RegisterAnalyzerForPort(const Tag& tag, TransportProto proto, uint #ifdef DEBUG const char* name = GetComponentName(tag).c_str(); - DBG_LOG(DBG_ANALYZER, "Registering analyzer %s for port %" PRIu32 "/%d", name, port, proto); + DBG_LOG(zeek::DBG_ANALYZER, "Registering analyzer %s for port %" PRIu32 "/%d", name, port, proto); #endif l->insert(tag); @@ -276,7 +276,7 @@ bool Manager::UnregisterAnalyzerForPort(const Tag& tag, TransportProto proto, ui #ifdef DEBUG const char* name = GetComponentName(tag).c_str(); - DBG_LOG(DBG_ANALYZER, "Unregistering analyzer %s for port %" PRIu32 "/%d", name, port, proto); + DBG_LOG(zeek::DBG_ANALYZER, "Unregistering analyzer %s for port %" PRIu32 "/%d", name, port, proto); #endif l->erase(tag); @@ -524,7 +524,7 @@ void Manager::ExpireScheduledAnalyzers() conns.erase(i); - DBG_LOG(DBG_ANALYZER, "Expiring expected analyzer %s for connection %s", + DBG_LOG(zeek::DBG_ANALYZER, "Expiring expected analyzer %s for connection %s", zeek::analyzer_mgr->GetComponentName(a->analyzer).c_str(), fmt_conn_id(a->conn.orig, 0, a->conn.resp, a->conn.resp_p)); diff --git a/src/analyzer/Manager.h b/src/analyzer/Manager.h index d03b1b3b62..5ea0ed21c2 100644 --- a/src/analyzer/Manager.h +++ b/src/analyzer/Manager.h @@ -416,11 +416,11 @@ extern zeek::analyzer::Manager*& analyzer_mgr [[deprecated("Remove in v4.1. Use // message. #ifdef DEBUG # define DBG_ANALYZER(conn, txt) \ - DBG_LOG(DBG_ANALYZER, "%s " txt, \ + DBG_LOG(zeek::DBG_ANALYZER, "%s " txt, \ fmt_conn_id(conn->OrigAddr(), ntohs(conn->OrigPort()), \ conn->RespAddr(), ntohs(conn->RespPort()))); # define DBG_ANALYZER_ARGS(conn, fmt, args...) \ - DBG_LOG(DBG_ANALYZER, "%s " fmt, \ + DBG_LOG(zeek::DBG_ANALYZER, "%s " fmt, \ fmt_conn_id(conn->OrigAddr(), ntohs(conn->OrigPort()), \ conn->RespAddr(), ntohs(conn->RespPort())), ##args); #else diff --git a/src/analyzer/protocol/pia/PIA.cc b/src/analyzer/protocol/pia/PIA.cc index d3833267b5..6af523f416 100644 --- a/src/analyzer/protocol/pia/PIA.cc +++ b/src/analyzer/protocol/pia/PIA.cc @@ -73,7 +73,7 @@ void PIA::AddToBuffer(Buffer* buffer, int len, const u_char* data, bool is_orig, void PIA::ReplayPacketBuffer(zeek::analyzer::Analyzer* analyzer) { - DBG_LOG(DBG_ANALYZER, "PIA replaying %d total packet bytes", pkt_buffer.size); + DBG_LOG(zeek::DBG_ANALYZER, "PIA replaying %d total packet bytes", pkt_buffer.size); for ( DataBlock* b = pkt_buffer.head; b; b = b->next ) analyzer->DeliverPacket(b->len, b->data, b->is_orig, -1, b->ip, 0); @@ -149,7 +149,7 @@ void PIA_UDP::ActivateAnalyzer(zeek::analyzer::Tag tag, const zeek::detail::Rule { if ( pkt_buffer.state == MATCHING_ONLY ) { - DBG_LOG(DBG_ANALYZER, "analyzer found but buffer already exceeded"); + DBG_LOG(zeek::DBG_ANALYZER, "analyzer found but buffer already exceeded"); // FIXME: This is where to check whether an analyzer // supports partial connections once we get such. @@ -210,7 +210,7 @@ void PIA_TCP::FirstPacket(bool is_orig, const zeek::IP_Hdr* ip) static struct tcphdr* tcp4 = nullptr; static zeek::IP_Hdr* ip4_hdr = nullptr; - DBG_LOG(DBG_ANALYZER, "PIA_TCP[%d] FirstPacket(%s)", GetID(), (is_orig ? "T" : "F")); + DBG_LOG(zeek::DBG_ANALYZER, "PIA_TCP[%d] FirstPacket(%s)", GetID(), (is_orig ? "T" : "F")); if ( ! ip ) { @@ -296,7 +296,7 @@ void PIA_TCP::ActivateAnalyzer(zeek::analyzer::Tag tag, const zeek::detail::Rule { if ( stream_buffer.state == MATCHING_ONLY ) { - DBG_LOG(DBG_ANALYZER, "analyzer found but buffer already exceeded"); + DBG_LOG(zeek::DBG_ANALYZER, "analyzer found but buffer already exceeded"); // FIXME: This is where to check whether an analyzer supports // partial connections once we get such. @@ -348,7 +348,7 @@ void PIA_TCP::ActivateAnalyzer(zeek::analyzer::Tag tag, const zeek::detail::Rule // (4) We hand the two reassemblers to the TCP Analyzer (our parent), // turning reassembly now on for all subsequent data. - DBG_LOG(DBG_ANALYZER, "PIA_TCP switching from packet-mode to stream-mode"); + DBG_LOG(zeek::DBG_ANALYZER, "PIA_TCP switching from packet-mode to stream-mode"); stream_mode = true; // FIXME: The reassembler will query the endpoint for state. Not sure @@ -425,7 +425,7 @@ void PIA_TCP::DeactivateAnalyzer(zeek::analyzer::Tag tag) void PIA_TCP::ReplayStreamBuffer(zeek::analyzer::Analyzer* analyzer) { - DBG_LOG(DBG_ANALYZER, "PIA_TCP replaying %d total stream bytes", stream_buffer.size); + DBG_LOG(zeek::DBG_ANALYZER, "PIA_TCP replaying %d total stream bytes", stream_buffer.size); for ( DataBlock* b = stream_buffer.head; b; b = b->next ) { diff --git a/src/analyzer/protocol/tcp/TCP.cc b/src/analyzer/protocol/tcp/TCP.cc index 6786e1757f..60844e0d8d 100644 --- a/src/analyzer/protocol/tcp/TCP.cc +++ b/src/analyzer/protocol/tcp/TCP.cc @@ -1247,7 +1247,7 @@ void TCP_Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig, if ( child->Removing() ) child->Done(); - DBG_LOG(DBG_ANALYZER, "%s deleted child %s", + DBG_LOG(zeek::DBG_ANALYZER, "%s deleted child %s", fmt_analyzer(this).c_str(), fmt_analyzer(child).c_str()); i = packet_children.erase(i); delete child; @@ -1763,7 +1763,7 @@ bool TCP_Analyzer::HadGap(bool is_orig) const void TCP_Analyzer::AddChildPacketAnalyzer(zeek::analyzer::Analyzer* a) { - DBG_LOG(DBG_ANALYZER, "%s added packet child %s", + DBG_LOG(zeek::DBG_ANALYZER, "%s added packet child %s", this->GetAnalyzerName(), a->GetAnalyzerName()); packet_children.push_back(a); @@ -1905,7 +1905,7 @@ void TCP_ApplicationAnalyzer::DeliverPacket(int len, const u_char* data, const zeek::IP_Hdr* ip, int caplen) { Analyzer::DeliverPacket(len, data, is_orig, seq, ip, caplen); - DBG_LOG(DBG_ANALYZER, "TCP_ApplicationAnalyzer ignoring DeliverPacket(%d, %s, %" PRIu64", %p, %d) [%s%s]", + DBG_LOG(zeek::DBG_ANALYZER, "TCP_ApplicationAnalyzer ignoring DeliverPacket(%d, %s, %" PRIu64", %p, %d) [%s%s]", len, is_orig ? "T" : "F", seq, ip, caplen, fmt_bytes((const char*) data, std::min(40, len)), len > 40 ? "..." : ""); } diff --git a/src/broker/Manager.cc b/src/broker/Manager.cc index 1c6729a3e1..6b8111488b 100644 --- a/src/broker/Manager.cc +++ b/src/broker/Manager.cc @@ -143,7 +143,7 @@ Manager::~Manager() void Manager::InitPostScript() { - DBG_LOG(DBG_BROKER, "Initializing"); + DBG_LOG(zeek::DBG_BROKER, "Initializing"); log_batch_size = get_option("Broker::log_batch_size")->AsCount(); default_log_topic_prefix = @@ -355,7 +355,7 @@ uint16_t Manager::Listen(const string& addr, uint16_t port) // Register as a "does-count" source now. iosource_mgr->Register(this, false); - DBG_LOG(DBG_BROKER, "Listening on %s:%" PRIu16, + DBG_LOG(zeek::DBG_BROKER, "Listening on %s:%" PRIu16, addr.empty() ? "INADDR_ANY" : addr.c_str(), port); return bound_port; @@ -366,7 +366,7 @@ void Manager::Peer(const string& addr, uint16_t port, double retry) if ( bstate->endpoint.is_shutdown() ) return; - DBG_LOG(DBG_BROKER, "Starting to peer with %s:%" PRIu16, + DBG_LOG(zeek::DBG_BROKER, "Starting to peer with %s:%" PRIu16, addr.c_str(), port); auto e = zeekenv("ZEEK_DEFAULT_CONNECT_RETRY"); @@ -393,7 +393,7 @@ void Manager::Unpeer(const string& addr, uint16_t port) if ( bstate->endpoint.is_shutdown() ) return; - DBG_LOG(DBG_BROKER, "Stopping to peer with %s:%" PRIu16, + DBG_LOG(zeek::DBG_BROKER, "Stopping to peer with %s:%" PRIu16, addr.c_str(), port); FlushLogBuffers(); @@ -421,7 +421,7 @@ bool Manager::PublishEvent(string topic, std::string name, broker::vector args) if ( peer_count == 0 ) return true; - DBG_LOG(DBG_BROKER, "Publishing event: %s", + DBG_LOG(zeek::DBG_BROKER, "Publishing event: %s", RenderEvent(topic, name, args).c_str()); broker::zeek::Event ev(std::move(name), std::move(args)); bstate->endpoint.publish(move(topic), ev.move_data()); @@ -485,7 +485,7 @@ bool Manager::PublishIdentifier(std::string topic, std::string id) } broker::zeek::IdentifierUpdate msg(move(id), move(*data)); - DBG_LOG(DBG_BROKER, "Publishing id-update: %s", + DBG_LOG(zeek::DBG_BROKER, "Publishing id-update: %s", RenderMessage(topic, msg.as_data()).c_str()); bstate->endpoint.publish(move(topic), msg.move_data()); ++statistics.num_ids_outgoing; @@ -537,7 +537,7 @@ bool Manager::PublishLogCreate(zeek::EnumVal* stream, zeek::EnumVal* writer, auto bwriter_id = broker::enum_value(move(writer_id)); broker::zeek::LogCreate msg(move(bstream_id), move(bwriter_id), move(writer_info), move(fields_data)); - DBG_LOG(DBG_BROKER, "Publishing log creation: %s", RenderMessage(topic, msg.as_data()).c_str()); + DBG_LOG(zeek::DBG_BROKER, "Publishing log creation: %s", RenderMessage(topic, msg.as_data()).c_str()); if ( peer.node != NoPeer.node ) // Direct message. @@ -622,7 +622,7 @@ bool Manager::PublishLogWrite(zeek::EnumVal* stream, zeek::EnumVal* writer, stri broker::zeek::LogWrite msg(move(bstream_id), move(bwriter_id), move(path), move(serial_data)); - DBG_LOG(DBG_BROKER, "Buffering log record: %s", RenderMessage(topic, msg.as_data()).c_str()); + DBG_LOG(zeek::DBG_BROKER, "Buffering log record: %s", RenderMessage(topic, msg.as_data()).c_str()); if ( log_buffers.size() <= (unsigned int)stream_id_num ) log_buffers.resize(stream_id_num + 1); @@ -665,7 +665,7 @@ size_t Manager::LogBuffer::Flush(broker::endpoint& endpoint, size_t log_batch_si size_t Manager::FlushLogBuffers() { - DBG_LOG(DBG_BROKER, "Flushing all log buffers"); + DBG_LOG(zeek::DBG_BROKER, "Flushing all log buffers"); auto rval = 0u; for ( auto& lb : log_buffers ) @@ -711,7 +711,7 @@ bool Manager::AutoPublishEvent(string topic, zeek::Val* event) return false; } - DBG_LOG(DBG_BROKER, "Enabling auto-publising of event %s to topic %s", handler->Name(), topic.c_str()); + DBG_LOG(zeek::DBG_BROKER, "Enabling auto-publising of event %s to topic %s", handler->Name(), topic.c_str()); handler->AutoPublish(move(topic)); return true; @@ -743,7 +743,7 @@ bool Manager::AutoUnpublishEvent(const string& topic, zeek::Val* event) } - DBG_LOG(DBG_BROKER, "Disabling auto-publishing of event %s to topic %s", handler->Name(), topic.c_str()); + DBG_LOG(zeek::DBG_BROKER, "Disabling auto-publishing of event %s to topic %s", handler->Name(), topic.c_str()); handler->AutoUnpublish(topic); return true; @@ -827,7 +827,7 @@ zeek::RecordVal* Manager::MakeEvent(val_list* args, zeek::detail::Frame* frame) bool Manager::Subscribe(const string& topic_prefix) { - DBG_LOG(DBG_BROKER, "Subscribing to topic prefix %s", topic_prefix.c_str()); + DBG_LOG(zeek::DBG_BROKER, "Subscribing to topic prefix %s", topic_prefix.c_str()); bstate->subscriber.add_topic(topic_prefix, ! after_zeek_init); // For backward compatibility, we also may receive messages on @@ -847,7 +847,7 @@ bool Manager::Forward(string topic_prefix) if ( prefix == topic_prefix ) return false; - DBG_LOG(DBG_BROKER, "Forwarding topic prefix %s", topic_prefix.c_str()); + DBG_LOG(zeek::DBG_BROKER, "Forwarding topic prefix %s", topic_prefix.c_str()); Subscribe(topic_prefix); forwarded_prefixes.emplace_back(std::move(topic_prefix)); return true; @@ -858,12 +858,12 @@ bool Manager::Unsubscribe(const string& topic_prefix) for ( size_t i = 0; i < forwarded_prefixes.size(); ++i ) if ( forwarded_prefixes[i] == topic_prefix ) { - DBG_LOG(DBG_BROKER, "Unforwading topic prefix %s", topic_prefix.c_str()); + DBG_LOG(zeek::DBG_BROKER, "Unforwading topic prefix %s", topic_prefix.c_str()); forwarded_prefixes.erase(forwarded_prefixes.begin() + i); break; } - DBG_LOG(DBG_BROKER, "Unsubscribing from topic prefix %s", topic_prefix.c_str()); + DBG_LOG(zeek::DBG_BROKER, "Unsubscribing from topic prefix %s", topic_prefix.c_str()); bstate->subscriber.remove_topic(topic_prefix, ! after_zeek_init); return true; } @@ -1016,11 +1016,11 @@ void Manager::ProcessStoreEventInsertUpdate(const zeek::TableValPtr& table, if ( insert ) { - DBG_LOG(DBG_BROKER, "Store %s: Insert: %s:%s (%s:%s)", store_id.c_str(), to_string(key).c_str(), to_string(data).c_str(), key.get_type_name(), data.get_type_name()); + DBG_LOG(zeek::DBG_BROKER, "Store %s: Insert: %s:%s (%s:%s)", store_id.c_str(), to_string(key).c_str(), to_string(data).c_str(), key.get_type_name(), data.get_type_name()); } else { - DBG_LOG(DBG_BROKER, "Store %s: Update: %s->%s (%s)", store_id.c_str(), to_string(old_value).c_str(), to_string(data).c_str(), data.get_type_name()); + DBG_LOG(zeek::DBG_BROKER, "Store %s: Update: %s->%s (%s)", store_id.c_str(), to_string(old_value).c_str(), to_string(data).c_str(), data.get_type_name()); } if ( table->GetType()->IsSet() && data.get_type() != broker::data::type::none ) @@ -1104,7 +1104,7 @@ void Manager::ProcessStoreEvent(broker::data msg) return; auto key = erase.key(); - DBG_LOG(DBG_BROKER, "Store %s: Erase key %s", erase.store_id().c_str(), to_string(key).c_str()); + DBG_LOG(zeek::DBG_BROKER, "Store %s: Erase key %s", erase.store_id().c_str(), to_string(key).c_str()); const auto& its = table->GetType()->AsTableType()->GetIndexTypes(); assert( its.size() == 1 ); auto zeek_key = data_to_val(key, its[0].get()); @@ -1129,7 +1129,7 @@ void Manager::ProcessStoreEvent(broker::data msg) if ( ! table ) return; - DBG_LOG(DBG_BROKER, "Store %s: Store expired key %s", expire.store_id().c_str(), to_string(expire.key()).c_str()); + DBG_LOG(zeek::DBG_BROKER, "Store %s: Store expired key %s", expire.store_id().c_str(), to_string(expire.key()).c_str()); #endif /* DEBUG */ } else @@ -1150,7 +1150,7 @@ void Manager::ProcessEvent(const broker::topic& topic, broker::zeek::Event ev) auto name = std::move(ev.name()); auto args = std::move(ev.args()); - DBG_LOG(DBG_BROKER, "Process event: %s %s", + DBG_LOG(zeek::DBG_BROKER, "Process event: %s %s", name.data(), RenderMessage(args).data()); ++statistics.num_events_incoming; auto handler = zeek::event_registry->Lookup(name); @@ -1168,7 +1168,7 @@ void Manager::ProcessEvent(const broker::topic& topic, broker::zeek::Event ev) if ( strncmp(p.data(), topic_string.data(), p.size()) != 0 ) continue; - DBG_LOG(DBG_BROKER, "Skip processing of forwarded event: %s %s", + DBG_LOG(zeek::DBG_BROKER, "Skip processing of forwarded event: %s %s", name.data(), RenderMessage(args).data()); return; } @@ -1221,7 +1221,7 @@ void Manager::ProcessEvent(const broker::topic& topic, broker::zeek::Event ev) bool bro_broker::Manager::ProcessLogCreate(broker::zeek::LogCreate lc) { - DBG_LOG(DBG_BROKER, "Received log-create: %s", RenderMessage(lc.as_data()).c_str()); + DBG_LOG(zeek::DBG_BROKER, "Received log-create: %s", RenderMessage(lc.as_data()).c_str()); if ( ! lc.valid() ) { zeek::reporter->Warning("received invalid broker LogCreate: %s", @@ -1286,7 +1286,7 @@ bool bro_broker::Manager::ProcessLogCreate(broker::zeek::LogCreate lc) bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw) { - DBG_LOG(DBG_BROKER, "Received log-write: %s", RenderMessage(lw.as_data()).c_str()); + DBG_LOG(zeek::DBG_BROKER, "Received log-write: %s", RenderMessage(lw.as_data()).c_str()); if ( ! lw.valid() ) { @@ -1370,7 +1370,7 @@ bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw) bool Manager::ProcessIdentifierUpdate(broker::zeek::IdentifierUpdate iu) { - DBG_LOG(DBG_BROKER, "Received id-update: %s", RenderMessage(iu.as_data()).c_str()); + DBG_LOG(zeek::DBG_BROKER, "Received id-update: %s", RenderMessage(iu.as_data()).c_str()); if ( ! iu.valid() ) { @@ -1406,7 +1406,7 @@ bool Manager::ProcessIdentifierUpdate(broker::zeek::IdentifierUpdate iu) void Manager::ProcessStatus(broker::status stat) { - DBG_LOG(DBG_BROKER, "Received status message: %s", RenderMessage(stat).c_str()); + DBG_LOG(zeek::DBG_BROKER, "Received status message: %s", RenderMessage(stat).c_str()); auto ctx = stat.context(); @@ -1474,7 +1474,7 @@ void Manager::ProcessStatus(broker::status stat) void Manager::ProcessError(broker::error err) { - DBG_LOG(DBG_BROKER, "Received error message: %s", RenderMessage(err).c_str()); + DBG_LOG(zeek::DBG_BROKER, "Received error message: %s", RenderMessage(err).c_str()); if ( ! Broker::error ) return; @@ -1509,7 +1509,7 @@ void Manager::ProcessError(broker::error err) void Manager::ProcessStoreResponse(StoreHandleVal* s, broker::store::response response) { - DBG_LOG(DBG_BROKER, "Received store response: %s", RenderMessage(response).c_str()); + DBG_LOG(zeek::DBG_BROKER, "Received store response: %s", RenderMessage(response).c_str()); auto request = pending_queries.find(std::make_pair(response.id, s)); @@ -1561,7 +1561,7 @@ StoreHandleVal* Manager::MakeMaster(const string& name, broker::backend type, if ( LookupStore(name) ) return nullptr; - DBG_LOG(DBG_BROKER, "Creating master for data store %s", name.c_str()); + DBG_LOG(zeek::DBG_BROKER, "Creating master for data store %s", name.c_str()); auto it = opts.find("path"); @@ -1679,7 +1679,7 @@ StoreHandleVal* Manager::MakeClone(const string& name, double resync_interval, if ( LookupStore(name) ) return nullptr; - DBG_LOG(DBG_BROKER, "Creating clone for data store %s", name.c_str()); + DBG_LOG(zeek::DBG_BROKER, "Creating clone for data store %s", name.c_str()); auto result = bstate->endpoint.attach_clone(name, resync_interval, stale_interval, @@ -1708,7 +1708,7 @@ StoreHandleVal* Manager::LookupStore(const string& name) bool Manager::CloseStore(const string& name) { - DBG_LOG(DBG_BROKER, "Closing data store %s", name.c_str()); + DBG_LOG(zeek::DBG_BROKER, "Closing data store %s", name.c_str()); auto s = data_stores.find(name); if ( s == data_stores.end() ) @@ -1764,7 +1764,7 @@ bool Manager::AddForwardedStore(const std::string& name, zeek::TableValPtr table return false; } - DBG_LOG(DBG_BROKER, "Adding table forward for data store %s", name.c_str()); + DBG_LOG(zeek::DBG_BROKER, "Adding table forward for data store %s", name.c_str()); forwarded_stores.emplace(name, std::move(table)); PrepareForwarding(name); @@ -1781,7 +1781,7 @@ void Manager::PrepareForwarding(const std::string &name) return; handle->forward_to = forwarded_stores.at(name); - DBG_LOG(DBG_BROKER, "Resolved table forward for data store %s", name.c_str()); + DBG_LOG(zeek::DBG_BROKER, "Resolved table forward for data store %s", name.c_str()); } } // namespace bro_broker diff --git a/src/file_analysis/Analyzer.cc b/src/file_analysis/Analyzer.cc index b39e29e96a..79d1f91101 100644 --- a/src/file_analysis/Analyzer.cc +++ b/src/file_analysis/Analyzer.cc @@ -8,7 +8,7 @@ file_analysis::ID file_analysis::Analyzer::id_counter = 0; file_analysis::Analyzer::~Analyzer() { - DBG_LOG(DBG_FILE_ANALYSIS, "Destroy file analyzer %s", + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "Destroy file analyzer %s", file_mgr->GetComponentName(tag).c_str()); } diff --git a/src/file_analysis/AnalyzerSet.cc b/src/file_analysis/AnalyzerSet.cc index f3ca03f733..51261e9e63 100644 --- a/src/file_analysis/AnalyzerSet.cc +++ b/src/file_analysis/AnalyzerSet.cc @@ -54,7 +54,7 @@ bool AnalyzerSet::Add(const file_analysis::Tag& tag, zeek::RecordValPtr args) if ( analyzer_map.Lookup(key.get()) ) { - DBG_LOG(DBG_FILE_ANALYSIS, "[%s] Instantiate analyzer %s skipped: already exists", + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "[%s] Instantiate analyzer %s skipped: already exists", file->GetID().c_str(), file_mgr->GetComponentName(tag).c_str()); @@ -89,7 +89,7 @@ bool AnalyzerSet::AddMod::Perform(AnalyzerSet* set) { if ( set->analyzer_map.Lookup(key.get()) ) { - DBG_LOG(DBG_FILE_ANALYSIS, "[%s] Add analyzer %s skipped: already exists", + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "[%s] Add analyzer %s skipped: already exists", a->GetFile()->GetID().c_str(), file_mgr->GetComponentName(a->Tag()).c_str()); @@ -120,12 +120,12 @@ bool AnalyzerSet::Remove(const file_analysis::Tag& tag, if ( ! a ) { - DBG_LOG(DBG_FILE_ANALYSIS, "[%s] Skip remove analyzer %s", + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "[%s] Skip remove analyzer %s", file->GetID().c_str(), file_mgr->GetComponentName(tag).c_str()); return false; } - DBG_LOG(DBG_FILE_ANALYSIS, "[%s] Remove analyzer %s", + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "[%s] Remove analyzer %s", file->GetID().c_str(), file_mgr->GetComponentName(tag).c_str()); @@ -186,7 +186,7 @@ file_analysis::Analyzer* AnalyzerSet::InstantiateAnalyzer(const Tag& tag, void AnalyzerSet::Insert(file_analysis::Analyzer* a, std::unique_ptr key) { - DBG_LOG(DBG_FILE_ANALYSIS, "[%s] Add analyzer %s", + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "[%s] Add analyzer %s", file->GetID().c_str(), file_mgr->GetComponentName(a->Tag()).c_str()); analyzer_map.Insert(key.get(), a); @@ -198,7 +198,7 @@ void AnalyzerSet::DrainModifications() if ( mod_queue.empty() ) return; - DBG_LOG(DBG_FILE_ANALYSIS, "[%s] Start analyzer mod queue flush", + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "[%s] Start analyzer mod queue flush", file->GetID().c_str()); do { @@ -207,6 +207,6 @@ void AnalyzerSet::DrainModifications() delete mod; mod_queue.pop(); } while ( ! mod_queue.empty() ); - DBG_LOG(DBG_FILE_ANALYSIS, "[%s] End flushing analyzer mod queue.", + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "[%s] End flushing analyzer mod queue.", file->GetID().c_str()); } diff --git a/src/file_analysis/File.cc b/src/file_analysis/File.cc index 17a80d983b..501e67a22c 100644 --- a/src/file_analysis/File.cc +++ b/src/file_analysis/File.cc @@ -89,7 +89,7 @@ File::File(const std::string& file_id, const std::string& source_name, Connectio { StaticInit(); - DBG_LOG(DBG_FILE_ANALYSIS, "[%s] Creating new File object", file_id.c_str()); + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "[%s] Creating new File object", file_id.c_str()); val = zeek::make_intrusive(zeek::id::fa_file); val->Assign(id_idx, zeek::make_intrusive(file_id.c_str())); @@ -106,7 +106,7 @@ File::File(const std::string& file_id, const std::string& source_name, Connectio File::~File() { - DBG_LOG(DBG_FILE_ANALYSIS, "[%s] Destroying File object", id.c_str()); + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "[%s] Destroying File object", id.c_str()); delete file_reassembler; for ( auto a : done_analyzers ) @@ -231,7 +231,7 @@ void File::IncrementByteCount(uint64_t size, int field_idx) void File::SetTotalBytes(uint64_t size) { - DBG_LOG(DBG_FILE_ANALYSIS, "[%s] Total bytes %" PRIu64, id.c_str(), size); + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "[%s] Total bytes %" PRIu64, id.c_str(), size); val->Assign(total_bytes_idx, zeek::val_mgr->Count(size)); } @@ -258,7 +258,7 @@ bool File::AddAnalyzer(file_analysis::Tag tag, zeek::RecordVal* args) bool File::AddAnalyzer(file_analysis::Tag tag, zeek::RecordValPtr args) { - DBG_LOG(DBG_FILE_ANALYSIS, "[%s] Queuing addition of %s analyzer", + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "[%s] Queuing addition of %s analyzer", id.c_str(), file_mgr->GetComponentName(tag).c_str()); if ( done ) @@ -272,7 +272,7 @@ bool File::RemoveAnalyzer(file_analysis::Tag tag, zeek::RecordVal* args) bool File::RemoveAnalyzer(file_analysis::Tag tag, zeek::RecordValPtr args) { - DBG_LOG(DBG_FILE_ANALYSIS, "[%s] Queuing remove of %s analyzer", + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "[%s] Queuing remove of %s analyzer", id.c_str(), file_mgr->GetComponentName(tag).c_str()); return done ? false : analyzers.QueueRemove(tag, std::move(args)); @@ -386,7 +386,7 @@ void File::DeliverStream(const u_char* data, uint64_t len) LookupFieldDefaultCount(missing_bytes_idx) == 0 ) InferMetadata(); - DBG_LOG(DBG_FILE_ANALYSIS, + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "[%s] %" PRIu64 " stream bytes in at offset %" PRIu64 "; %s [%s%s]", id.c_str(), len, stream_offset, IsComplete() ? "complete" : "incomplete", @@ -398,10 +398,10 @@ void File::DeliverStream(const u_char* data, uint64_t len) while ( (a = analyzers.NextEntry(c)) ) { - DBG_LOG(DBG_FILE_ANALYSIS, "stream delivery to analyzer %s", file_mgr->GetComponentName(a->Tag()).c_str()); + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "stream delivery to analyzer %s", file_mgr->GetComponentName(a->Tag()).c_str()); if ( ! a->GotStreamDelivery() ) { - DBG_LOG(DBG_FILE_ANALYSIS, "skipping stream delivery to analyzer %s", file_mgr->GetComponentName(a->Tag()).c_str()); + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "skipping stream delivery to analyzer %s", file_mgr->GetComponentName(a->Tag()).c_str()); int num_bof_chunks_behind = bof_buffer.chunks.size(); if ( ! bof_was_full ) @@ -490,7 +490,7 @@ void File::DeliverChunk(const u_char* data, uint64_t len, uint64_t offset) IncrementByteCount(len, overflow_bytes_idx); } - DBG_LOG(DBG_FILE_ANALYSIS, + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "[%s] %" PRIu64 " chunk bytes in at offset %" PRIu64 "; %s [%s%s]", id.c_str(), len, offset, IsComplete() ? "complete" : "incomplete", @@ -502,7 +502,7 @@ void File::DeliverChunk(const u_char* data, uint64_t len, uint64_t offset) while ( (a = analyzers.NextEntry(c)) ) { - DBG_LOG(DBG_FILE_ANALYSIS, "chunk delivery to analyzer %s", file_mgr->GetComponentName(a->Tag()).c_str()); + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "chunk delivery to analyzer %s", file_mgr->GetComponentName(a->Tag()).c_str()); if ( ! a->Skipping() ) { if ( ! a->DeliverChunk(data, len, offset) ) @@ -538,7 +538,7 @@ void File::DataIn(const u_char* data, uint64_t len) void File::EndOfFile() { - DBG_LOG(DBG_FILE_ANALYSIS, "[%s] End of file", id.c_str()); + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "[%s] End of file", id.c_str()); if ( done ) return; @@ -553,7 +553,7 @@ void File::EndOfFile() // any stream analyzers. if ( ! bof_buffer.full ) { - DBG_LOG(DBG_FILE_ANALYSIS, "[%s] File over but bof_buffer not full.", id.c_str()); + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "[%s] File over but bof_buffer not full.", id.c_str()); bof_buffer.full = true; DeliverStream((const u_char*) "", 0); } @@ -577,7 +577,7 @@ void File::EndOfFile() void File::Gap(uint64_t offset, uint64_t len) { - DBG_LOG(DBG_FILE_ANALYSIS, "[%s] Gap of size %" PRIu64 " at offset %" PRIu64, + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "[%s] Gap of size %" PRIu64 " at offset %" PRIu64, id.c_str(), len, offset); if ( file_reassembler && ! file_reassembler->IsCurrentlyFlushing() ) @@ -589,7 +589,7 @@ void File::Gap(uint64_t offset, uint64_t len) if ( ! bof_buffer.full ) { - DBG_LOG(DBG_FILE_ANALYSIS, "[%s] File gap before bof_buffer filled, continued without attempting to fill bof_buffer.", id.c_str()); + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "[%s] File gap before bof_buffer filled, continued without attempting to fill bof_buffer.", id.c_str()); bof_buffer.full = true; DeliverStream((const u_char*) "", 0); } diff --git a/src/file_analysis/FileTimer.cc b/src/file_analysis/FileTimer.cc index af8d415b19..dce4d46d33 100644 --- a/src/file_analysis/FileTimer.cc +++ b/src/file_analysis/FileTimer.cc @@ -9,7 +9,7 @@ using namespace file_analysis; FileTimer::FileTimer(double t, const std::string& id, double interval) : zeek::detail::Timer(t + interval, zeek::detail::TIMER_FILE_ANALYSIS_INACTIVITY), file_id(id) { - DBG_LOG(DBG_FILE_ANALYSIS, "New %f second timeout timer for %s", + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "New %f second timeout timer for %s", interval, file_id.c_str()); } @@ -23,7 +23,7 @@ void FileTimer::Dispatch(double t, bool is_expire) double last_active = file->GetLastActivityTime(); double inactive_time = t > last_active ? t - last_active : 0.0; - DBG_LOG(DBG_FILE_ANALYSIS, "Checking inactivity for %s, last active at %f, " + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "Checking inactivity for %s, last active at %f, " "inactive for %f", file_id.c_str(), last_active, inactive_time); if ( last_active == 0.0 ) diff --git a/src/file_analysis/Manager.cc b/src/file_analysis/Manager.cc index 1be5e43be5..bd4785f758 100644 --- a/src/file_analysis/Manager.cc +++ b/src/file_analysis/Manager.cc @@ -78,11 +78,11 @@ void Manager::SetHandle(const string& handle) return; #ifdef DEBUG - if ( debug_logger.IsEnabled(DBG_FILE_ANALYSIS) ) + if ( debug_logger.IsEnabled(zeek::DBG_FILE_ANALYSIS) ) { zeek::String tmp{handle}; auto rendered = tmp.Render(); - DBG_LOG(DBG_FILE_ANALYSIS, "Set current handle to %s", rendered); + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "Set current handle to %s", rendered); delete [] rendered; } #endif @@ -371,14 +371,14 @@ void Manager::Timeout(const string& file_id, bool is_terminating) if ( file->postpone_timeout && ! is_terminating ) { - DBG_LOG(DBG_FILE_ANALYSIS, "Postpone file analysis timeout for %s", + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "Postpone file analysis timeout for %s", file->GetID().c_str()); file->UpdateLastActivityTime(); file->ScheduleInactivityTimer(); return; } - DBG_LOG(DBG_FILE_ANALYSIS, "File analysis timeout for %s", + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "File analysis timeout for %s", file->GetID().c_str()); RemoveFile(file->GetID()); @@ -389,7 +389,7 @@ bool Manager::IgnoreFile(const string& file_id) if ( ! LookupFile(file_id) ) return false; - DBG_LOG(DBG_FILE_ANALYSIS, "Ignore FileID %s", file_id.c_str()); + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "Ignore FileID %s", file_id.c_str()); ignored.insert(file_id); return true; @@ -405,7 +405,7 @@ bool Manager::RemoveFile(const string& file_id) if ( ! f ) return false; - DBG_LOG(DBG_FILE_ANALYSIS, "[%s] Remove file", file_id.c_str()); + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "[%s] Remove file", file_id.c_str()); f->EndOfFile(); @@ -430,7 +430,7 @@ string Manager::GetFileID(const zeek::analyzer::Tag& tag, Connection* c, bool is if ( ! get_file_handle ) return ""; - DBG_LOG(DBG_FILE_ANALYSIS, "Raise get_file_handle() for protocol analyzer %s", + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "Raise get_file_handle() for protocol analyzer %s", zeek::analyzer_mgr->GetComponentName(tag).c_str()); const auto& tagval = tag.AsVal(); @@ -471,7 +471,7 @@ Analyzer* Manager::InstantiateAnalyzer(const Tag& tag, return nullptr; } - DBG_LOG(DBG_FILE_ANALYSIS, "[%s] Instantiate analyzer %s", + DBG_LOG(zeek::DBG_FILE_ANALYSIS, "[%s] Instantiate analyzer %s", f->id.c_str(), GetComponentName(tag).c_str()); Analyzer* a; diff --git a/src/input/Manager.cc b/src/input/Manager.cc index b4cbaf0bb0..337eefcc1e 100644 --- a/src/input/Manager.cc +++ b/src/input/Manager.cc @@ -297,7 +297,7 @@ bool Manager::CreateStream(Stream* info, zeek::RecordVal* description) info->description = description; - DBG_LOG(DBG_INPUT, "Successfully created new input stream %s", + DBG_LOG(zeek::DBG_INPUT, "Successfully created new input stream %s", name.c_str()); return true; @@ -451,7 +451,7 @@ bool Manager::CreateEventStream(zeek::RecordVal* fval) readers[stream->reader] = stream; - DBG_LOG(DBG_INPUT, "Successfully created event stream %s", + DBG_LOG(zeek::DBG_INPUT, "Successfully created event stream %s", stream->name.c_str()); return true; @@ -707,7 +707,7 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval) readers[stream->reader] = stream; - DBG_LOG(DBG_INPUT, "Successfully created table stream %s", + DBG_LOG(zeek::DBG_INPUT, "Successfully created table stream %s", stream->name.c_str()); return true; @@ -794,7 +794,7 @@ bool Manager::CreateAnalysisStream(zeek::RecordVal* fval) readers[stream->reader] = stream; - DBG_LOG(DBG_INPUT, "Successfully created analysis stream %s", + DBG_LOG(zeek::DBG_INPUT, "Successfully created analysis stream %s", stream->name.c_str()); return true; @@ -864,7 +864,7 @@ bool Manager::RemoveStream(Stream *i) i->removed = true; - DBG_LOG(DBG_INPUT, "Successfully queued removal of stream %s", + DBG_LOG(zeek::DBG_INPUT, "Successfully queued removal of stream %s", i->name.c_str()); i->reader->Stop(); @@ -895,7 +895,7 @@ bool Manager::RemoveStreamContinuation(ReaderFrontend* reader) } #ifdef DEBUG - DBG_LOG(DBG_INPUT, "Successfully executed removal of stream %s", + DBG_LOG(zeek::DBG_INPUT, "Successfully executed removal of stream %s", i->name.c_str()); #endif @@ -1009,7 +1009,7 @@ bool Manager::ForceUpdate(const string &name) i->reader->Update(); #ifdef DEBUG - DBG_LOG(DBG_INPUT, "Forcing update of stream %s", name.c_str()); + DBG_LOG(zeek::DBG_INPUT, "Forcing update of stream %s", name.c_str()); #endif return true; // update is async :( @@ -1326,13 +1326,13 @@ void Manager::EndCurrentSend(ReaderFrontend* reader) } #ifdef DEBUG - DBG_LOG(DBG_INPUT, "Got EndCurrentSend stream %s", i->name.c_str()); + DBG_LOG(zeek::DBG_INPUT, "Got EndCurrentSend stream %s", i->name.c_str()); #endif if ( i->stream_type != TABLE_STREAM ) { #ifdef DEBUG - DBG_LOG(DBG_INPUT, "%s is event, sending end of data", i->name.c_str()); + DBG_LOG(zeek::DBG_INPUT, "%s is event, sending end of data", i->name.c_str()); #endif // just signal the end of the data source SendEndOfData(i); @@ -1406,7 +1406,7 @@ void Manager::EndCurrentSend(ReaderFrontend* reader) stream->currDict->SetDeleteFunc(input_hash_delete_func); #ifdef DEBUG - DBG_LOG(DBG_INPUT, "EndCurrentSend complete for stream %s", + DBG_LOG(zeek::DBG_INPUT, "EndCurrentSend complete for stream %s", i->name.c_str()); #endif @@ -1431,7 +1431,7 @@ void Manager::SendEndOfData(ReaderFrontend* reader) void Manager::SendEndOfData(const Stream *i) { #ifdef DEBUG - DBG_LOG(DBG_INPUT, "SendEndOfData for stream %s", + DBG_LOG(zeek::DBG_INPUT, "SendEndOfData for stream %s", i->name.c_str()); #endif SendEvent(end_of_data, 2, new zeek::StringVal(i->name.c_str()), @@ -1451,7 +1451,7 @@ void Manager::Put(ReaderFrontend* reader, Value* *vals) } #ifdef DEBUG - DBG_LOG(DBG_INPUT, "Put for stream %s", + DBG_LOG(zeek::DBG_INPUT, "Put for stream %s", i->name.c_str()); #endif @@ -1680,7 +1680,7 @@ void Manager::Clear(ReaderFrontend* reader) } #ifdef DEBUG - DBG_LOG(DBG_INPUT, "Got Clear for stream %s", + DBG_LOG(zeek::DBG_INPUT, "Got Clear for stream %s", i->name.c_str()); #endif @@ -1816,7 +1816,7 @@ void Manager::SendEvent(zeek::EventHandlerPtr ev, const int numvals, ...) const vl.reserve(numvals); #ifdef DEBUG - DBG_LOG(DBG_INPUT, "SendEvent with %d vals", + DBG_LOG(zeek::DBG_INPUT, "SendEvent with %d vals", numvals); #endif @@ -1837,7 +1837,7 @@ void Manager::SendEvent(zeek::EventHandlerPtr ev, list events) const vl.reserve(events.size()); #ifdef DEBUG - DBG_LOG(DBG_INPUT, "SendEvent with %" PRIuPTR " vals (list)", + DBG_LOG(zeek::DBG_INPUT, "SendEvent with %" PRIuPTR " vals (list)", events.size()); #endif diff --git a/src/input/readers/binary/Binary.cc b/src/input/readers/binary/Binary.cc index d181315a74..8d17e2ff01 100644 --- a/src/input/readers/binary/Binary.cc +++ b/src/input/readers/binary/Binary.cc @@ -60,7 +60,7 @@ bool Binary::CloseInput() } #ifdef DEBUG - Debug(DBG_INPUT, "Binary reader starting close"); + Debug(zeek::DBG_INPUT, "Binary reader starting close"); #endif in->close(); @@ -68,7 +68,7 @@ bool Binary::CloseInput() in = nullptr; #ifdef DEBUG - Debug(DBG_INPUT, "Binary reader finished close"); + Debug(zeek::DBG_INPUT, "Binary reader finished close"); #endif return true; @@ -129,14 +129,14 @@ bool Binary::DoInit(const ReaderInfo& info, int num_fields, return false; #ifdef DEBUG - Debug(DBG_INPUT, "Binary reader created, will perform first update"); + Debug(zeek::DBG_INPUT, "Binary reader created, will perform first update"); #endif // after initialization - do update DoUpdate(); #ifdef DEBUG - Debug(DBG_INPUT, "Binary reader did first update"); + Debug(zeek::DBG_INPUT, "Binary reader did first update"); #endif return true; @@ -256,7 +256,7 @@ bool Binary::DoUpdate() EndCurrentSend(); #ifdef DEBUG - Debug(DBG_INPUT, "DoUpdate finished successfully"); + Debug(zeek::DBG_INPUT, "DoUpdate finished successfully"); #endif return true; @@ -272,12 +272,12 @@ bool Binary::DoHeartbeat(double network_time, double current_time) case MODE_REREAD: case MODE_STREAM: #ifdef DEBUG - Debug(DBG_INPUT, "Starting Heartbeat update"); + Debug(zeek::DBG_INPUT, "Starting Heartbeat update"); #endif Update(); // call update and not DoUpdate, because update // checks disabled. #ifdef DEBUG - Debug(DBG_INPUT, "Finished with heartbeat update"); + Debug(zeek::DBG_INPUT, "Finished with heartbeat update"); #endif break; default: diff --git a/src/input/readers/raw/Raw.cc b/src/input/readers/raw/Raw.cc index 3e29ac8908..b859e6e195 100644 --- a/src/input/readers/raw/Raw.cc +++ b/src/input/readers/raw/Raw.cc @@ -311,7 +311,7 @@ bool Raw::CloseInput() return false; } #ifdef DEBUG - Debug(DBG_INPUT, "Raw reader starting close"); + Debug(zeek::DBG_INPUT, "Raw reader starting close"); #endif file.reset(nullptr); @@ -326,7 +326,7 @@ bool Raw::CloseInput() } #ifdef DEBUG - Debug(DBG_INPUT, "Raw reader finished close"); + Debug(zeek::DBG_INPUT, "Raw reader finished close"); #endif return true; @@ -421,14 +421,14 @@ bool Raw::DoInit(const ReaderInfo& info, int num_fields, const Field* const* fie return result; #ifdef DEBUG - Debug(DBG_INPUT, "Raw reader created, will perform first update"); + Debug(zeek::DBG_INPUT, "Raw reader created, will perform first update"); #endif // after initialization - do update DoUpdate(); #ifdef DEBUG - Debug(DBG_INPUT, "First update went through"); + Debug(zeek::DBG_INPUT, "First update went through"); #endif return true; } @@ -697,7 +697,7 @@ bool Raw::DoUpdate() #ifdef DEBUG - Debug(DBG_INPUT, "DoUpdate finished successfully"); + Debug(zeek::DBG_INPUT, "DoUpdate finished successfully"); #endif return true; @@ -713,12 +713,12 @@ bool Raw::DoHeartbeat(double network_time, double current_time) case MODE_REREAD: case MODE_STREAM: #ifdef DEBUG - Debug(DBG_INPUT, "Starting Heartbeat update"); + Debug(zeek::DBG_INPUT, "Starting Heartbeat update"); #endif Update(); // call update and not DoUpdate, because update // checks disabled. #ifdef DEBUG - Debug(DBG_INPUT, "Finished with heartbeat update"); + Debug(zeek::DBG_INPUT, "Finished with heartbeat update"); #endif break; default: diff --git a/src/iosource/Manager.cc b/src/iosource/Manager.cc index db4a636eb3..de07a87bfa 100644 --- a/src/iosource/Manager.cc +++ b/src/iosource/Manager.cc @@ -40,7 +40,7 @@ void Manager::WakeupHandler::Process() void Manager::WakeupHandler::Ping(const std::string& where) { - DBG_LOG(DBG_MAINLOOP, "Pinging WakeupHandler from %s", where.c_str()); + DBG_LOG(zeek::DBG_MAINLOOP, "Pinging WakeupHandler from %s", where.c_str()); flare.Fire(); } @@ -174,7 +174,7 @@ void Manager::FindReadySources(std::vector* ready) } } - DBG_LOG(DBG_MAINLOOP, "timeout: %f ready size: %zu time_to_poll: %d\n", + DBG_LOG(zeek::DBG_MAINLOOP, "timeout: %f ready size: %zu time_to_poll: %d\n", timeout, ready->size(), time_to_poll); // If we didn't find any IOSources with zero timeouts or it's time to @@ -243,7 +243,7 @@ bool Manager::RegisterFd(int fd, IOSource* src) if ( ret != -1 ) { events.push_back({}); - DBG_LOG(DBG_MAINLOOP, "Registered fd %d from %s", fd, src->Tag()); + DBG_LOG(zeek::DBG_MAINLOOP, "Registered fd %d from %s", fd, src->Tag()); fd_map[fd] = src; Wakeup("RegisterFd"); @@ -264,7 +264,7 @@ bool Manager::UnregisterFd(int fd, IOSource* src) EV_SET(&event, fd, EVFILT_READ, EV_DELETE, 0, 0, NULL); int ret = kevent(event_queue, &event, 1, NULL, 0, NULL); if ( ret != -1 ) - DBG_LOG(DBG_MAINLOOP, "Unregistered fd %d from %s", fd, src->Tag()); + DBG_LOG(zeek::DBG_MAINLOOP, "Unregistered fd %d from %s", fd, src->Tag()); fd_map.erase(fd); @@ -371,7 +371,7 @@ PktSrc* Manager::OpenPktSrc(const std::string& path, bool is_live) PktSrc* ps = (*component->Factory())(npath, is_live); assert(ps); - DBG_LOG(DBG_PKTIO, "Created packet source of type %s for %s", component->Name().c_str(), npath.c_str()); + DBG_LOG(zeek::DBG_PKTIO, "Created packet source of type %s for %s", component->Name().c_str(), npath.c_str()); Register(ps); return ps; @@ -410,7 +410,7 @@ PktDumper* Manager::OpenPktDumper(const std::string& path, bool append) // Set an error message if it didn't open successfully. pd->Error("could not open"); - DBG_LOG(DBG_PKTIO, "Created packer dumper of type %s for %s", component->Name().c_str(), npath.c_str()); + DBG_LOG(zeek::DBG_PKTIO, "Created packer dumper of type %s for %s", component->Name().c_str(), npath.c_str()); pd->Init(); pkt_dumpers.push_back(pd); diff --git a/src/iosource/PktDumper.cc b/src/iosource/PktDumper.cc index f0d911b9b4..1ada2a3021 100644 --- a/src/iosource/PktDumper.cc +++ b/src/iosource/PktDumper.cc @@ -62,13 +62,13 @@ void PktDumper::Opened(const Properties& arg_props) { is_open = true; props = arg_props; - DBG_LOG(DBG_PKTIO, "Opened dumper %s", props.path.c_str()); + DBG_LOG(zeek::DBG_PKTIO, "Opened dumper %s", props.path.c_str()); } void PktDumper::Closed() { is_open = false; - DBG_LOG(DBG_PKTIO, "Closed dumper %s", props.path.c_str()); + DBG_LOG(zeek::DBG_PKTIO, "Closed dumper %s", props.path.c_str()); props.path = ""; } @@ -76,7 +76,7 @@ void PktDumper::Error(const std::string& msg) { errmsg = msg; - DBG_LOG(DBG_PKTIO, "Error with dumper %s: %s", + DBG_LOG(zeek::DBG_PKTIO, "Error with dumper %s: %s", IsOpen() ? props.path.c_str() : "", msg.c_str()); } diff --git a/src/iosource/PktSrc.cc b/src/iosource/PktSrc.cc index 83b9dd679f..27fe7657b1 100644 --- a/src/iosource/PktSrc.cc +++ b/src/iosource/PktSrc.cc @@ -123,7 +123,7 @@ void PktSrc::Opened(const Properties& arg_props) zeek::reporter->FatalError("Failed to register pktsrc fd with iosource_mgr"); } - DBG_LOG(DBG_PKTIO, "Opened source %s", props.path.c_str()); + DBG_LOG(zeek::DBG_PKTIO, "Opened source %s", props.path.c_str()); } void PktSrc::Closed() @@ -133,7 +133,7 @@ void PktSrc::Closed() if ( props.is_live && props.selectable_fd != -1 ) iosource_mgr->UnregisterFd(props.selectable_fd, this); - DBG_LOG(DBG_PKTIO, "Closed source %s", props.path.c_str()); + DBG_LOG(zeek::DBG_PKTIO, "Closed source %s", props.path.c_str()); } void PktSrc::Error(const std::string& msg) @@ -141,7 +141,7 @@ void PktSrc::Error(const std::string& msg) // We don't report this immediately, Bro will ask us for the error // once it notices we aren't open. errbuf = msg; - DBG_LOG(DBG_PKTIO, "Error with source %s: %s", + DBG_LOG(zeek::DBG_PKTIO, "Error with source %s: %s", IsOpen() ? props.path.c_str() : "", msg.c_str()); } diff --git a/src/logging/Manager.cc b/src/logging/Manager.cc index 7aad7753c3..de3b14b605 100644 --- a/src/logging/Manager.cc +++ b/src/logging/Manager.cc @@ -319,7 +319,7 @@ bool Manager::CreateStream(zeek::EnumVal* id, zeek::RecordVal* sval) streams[idx]->enable_remote = zeek::id::find_val("Log::enable_remote_logging")->AsBool(); - DBG_LOG(DBG_LOGGING, "Created new logging stream '%s', raising event %s", + DBG_LOG(zeek::DBG_LOGGING, "Created new logging stream '%s', raising event %s", streams[idx]->name.c_str(), event ? streams[idx]->event->Name() : ""); return true; @@ -341,7 +341,7 @@ bool Manager::RemoveStream(zeek::EnumVal* id) { WriterInfo* winfo = i->second; - DBG_LOG(DBG_LOGGING, "Removed writer '%s' from stream '%s'", + DBG_LOG(zeek::DBG_LOGGING, "Removed writer '%s' from stream '%s'", winfo->writer->Name(), stream->name.c_str()); winfo->writer->Stop(); @@ -354,7 +354,7 @@ bool Manager::RemoveStream(zeek::EnumVal* id) delete stream; streams[idx] = nullptr; - DBG_LOG(DBG_LOGGING, "Removed logging stream '%s'", sname.c_str()); + DBG_LOG(zeek::DBG_LOGGING, "Removed logging stream '%s'", sname.c_str()); return true; } @@ -370,7 +370,7 @@ bool Manager::EnableStream(zeek::EnumVal* id) stream->enabled = true; - DBG_LOG(DBG_LOGGING, "Reenabled logging stream '%s'", stream->name.c_str()); + DBG_LOG(zeek::DBG_LOGGING, "Reenabled logging stream '%s'", stream->name.c_str()); return true; } @@ -386,7 +386,7 @@ bool Manager::DisableStream(zeek::EnumVal* id) stream->enabled = false; - DBG_LOG(DBG_LOGGING, "Disabled logging stream '%s'", stream->name.c_str()); + DBG_LOG(zeek::DBG_LOGGING, "Disabled logging stream '%s'", stream->name.c_str()); return true; } @@ -641,18 +641,18 @@ bool Manager::AddFilter(zeek::EnumVal* id, zeek::RecordVal* fval) ODesc desc; writer->Describe(&desc); - DBG_LOG(DBG_LOGGING, "Created new filter '%s' for stream '%s'", + DBG_LOG(zeek::DBG_LOGGING, "Created new filter '%s' for stream '%s'", filter->name.c_str(), stream->name.c_str()); - DBG_LOG(DBG_LOGGING, " writer : %s", desc.Description()); - DBG_LOG(DBG_LOGGING, " path : %s", filter->path.c_str()); - DBG_LOG(DBG_LOGGING, " path_func : %s", (filter->path_func ? "set" : "not set")); - DBG_LOG(DBG_LOGGING, " pred : %s", (filter->pred ? "set" : "not set")); + DBG_LOG(zeek::DBG_LOGGING, " writer : %s", desc.Description()); + DBG_LOG(zeek::DBG_LOGGING, " path : %s", filter->path.c_str()); + DBG_LOG(zeek::DBG_LOGGING, " path_func : %s", (filter->path_func ? "set" : "not set")); + DBG_LOG(zeek::DBG_LOGGING, " pred : %s", (filter->pred ? "set" : "not set")); for ( int i = 0; i < filter->num_fields; i++ ) { threading::Field* field = filter->fields[i]; - DBG_LOG(DBG_LOGGING, " field %10s: %s", + DBG_LOG(zeek::DBG_LOGGING, " field %10s: %s", field->name, zeek::type_name(field->type)); } #endif @@ -678,7 +678,7 @@ bool Manager::RemoveFilter(zeek::EnumVal* id, const string& name) { Filter* filter = *i; stream->filters.erase(i); - DBG_LOG(DBG_LOGGING, "Removed filter '%s' from stream '%s'", + DBG_LOG(zeek::DBG_LOGGING, "Removed filter '%s' from stream '%s'", filter->name.c_str(), stream->name.c_str()); delete filter; return true; @@ -686,7 +686,7 @@ bool Manager::RemoveFilter(zeek::EnumVal* id, const string& name) } // If we don't find the filter, we don't treat that as an error. - DBG_LOG(DBG_LOGGING, "No filter '%s' for removing from stream '%s'", + DBG_LOG(zeek::DBG_LOGGING, "No filter '%s' for removing from stream '%s'", name.c_str(), stream->name.c_str()); return true; @@ -774,7 +774,7 @@ bool Manager::Write(zeek::EnumVal* id, zeek::RecordVal* columns_arg) path = v->AsString()->CheckString(); #ifdef DEBUG - DBG_LOG(DBG_LOGGING, "Path function for filter '%s' on stream '%s' return '%s'", + DBG_LOG(zeek::DBG_LOGGING, "Path function for filter '%s' on stream '%s' return '%s'", filter->name.c_str(), stream->name.c_str(), path.c_str()); #endif } @@ -901,7 +901,7 @@ bool Manager::Write(zeek::EnumVal* id, zeek::RecordVal* columns_arg) DeleteVals(filter->num_fields, vals); #ifdef DEBUG - DBG_LOG(DBG_LOGGING, "Hook prevented writing to filter '%s' on stream '%s'", + DBG_LOG(zeek::DBG_LOGGING, "Hook prevented writing to filter '%s' on stream '%s'", filter->name.c_str(), stream->name.c_str()); #endif return true; @@ -912,7 +912,7 @@ bool Manager::Write(zeek::EnumVal* id, zeek::RecordVal* columns_arg) writer->Write(filter->num_fields, vals); #ifdef DEBUG - DBG_LOG(DBG_LOGGING, "Wrote record to filter '%s' on stream '%s'", + DBG_LOG(zeek::DBG_LOGGING, "Wrote record to filter '%s' on stream '%s'", filter->name.c_str(), stream->name.c_str()); #endif } @@ -1254,7 +1254,7 @@ bool Manager::WriteFromRemote(zeek::EnumVal* id, zeek::EnumVal* writer, const st #ifdef DEBUG ODesc desc; id->Describe(&desc); - DBG_LOG(DBG_LOGGING, "unknown stream %s in Manager::Write()", + DBG_LOG(zeek::DBG_LOGGING, "unknown stream %s in Manager::Write()", desc.Description()); #endif DeleteVals(num_fields, vals); @@ -1276,7 +1276,7 @@ bool Manager::WriteFromRemote(zeek::EnumVal* id, zeek::EnumVal* writer, const st #ifdef DEBUG ODesc desc; id->Describe(&desc); - DBG_LOG(DBG_LOGGING, "unknown writer %s in Manager::Write()", + DBG_LOG(zeek::DBG_LOGGING, "unknown writer %s in Manager::Write()", desc.Description()); #endif DeleteVals(num_fields, vals); @@ -1285,7 +1285,7 @@ bool Manager::WriteFromRemote(zeek::EnumVal* id, zeek::EnumVal* writer, const st w->second->writer->Write(num_fields, vals); - DBG_LOG(DBG_LOGGING, + DBG_LOG(zeek::DBG_LOGGING, "Wrote pre-filtered record to path '%s' on stream '%s'", path.c_str(), stream->name.c_str()); @@ -1484,7 +1484,7 @@ void Manager::InstallRotationTimer(WriterInfo* winfo) zeek::detail::timer_mgr->Add(winfo->rotation_timer); - DBG_LOG(DBG_LOGGING, "Scheduled rotation timer for %s to %.6f", + DBG_LOG(zeek::DBG_LOGGING, "Scheduled rotation timer for %s to %.6f", winfo->writer->Name(), winfo->rotation_timer->Time()); } } @@ -1552,7 +1552,7 @@ std::string Manager::FormatRotationPath(zeek::EnumValPtr writer, void Manager::Rotate(WriterInfo* winfo) { - DBG_LOG(DBG_LOGGING, "Rotating %s at %.6f", + DBG_LOG(zeek::DBG_LOGGING, "Rotating %s at %.6f", winfo->writer->Name(), network_time); static auto default_ppf = zeek::id::find_func("Log::__default_rotation_postprocessor"); @@ -1584,12 +1584,12 @@ bool Manager::FinishedRotation(WriterFrontend* writer, const char* new_name, con if ( ! success ) { - DBG_LOG(DBG_LOGGING, "Non-successful rotating writer '%s', file '%s' at %.6f,", + DBG_LOG(zeek::DBG_LOGGING, "Non-successful rotating writer '%s', file '%s' at %.6f,", writer->Name(), filename, network_time); return true; } - DBG_LOG(DBG_LOGGING, "Finished rotating %s at %.6f, new name %s", + DBG_LOG(zeek::DBG_LOGGING, "Finished rotating %s at %.6f, new name %s", writer->Name(), network_time, new_name); WriterInfo* winfo = FindWriter(writer); diff --git a/src/logging/WriterBackend.cc b/src/logging/WriterBackend.cc index fc1e97a3f0..9bb691c594 100644 --- a/src/logging/WriterBackend.cc +++ b/src/logging/WriterBackend.cc @@ -209,7 +209,7 @@ bool WriterBackend::Write(int arg_num_fields, int num_writes, Value*** vals) #ifdef DEBUG const char* msg = Fmt("Number of fields don't match in WriterBackend::Write() (%d vs. %d)", arg_num_fields, num_fields); - Debug(DBG_LOGGING, msg); + Debug(zeek::DBG_LOGGING, msg); #endif DeleteVals(num_writes, vals); @@ -227,7 +227,7 @@ bool WriterBackend::Write(int arg_num_fields, int num_writes, Value*** vals) #ifdef DEBUG const char* msg = Fmt("Field #%d type doesn't match in WriterBackend::Write() (%d vs. %d)", i, vals[j][i]->type, fields[i]->type); - Debug(DBG_LOGGING, msg); + Debug(zeek::DBG_LOGGING, msg); #endif DisableFrontend(); DeleteVals(num_writes, vals); diff --git a/src/plugin/ComponentManager.h b/src/plugin/ComponentManager.h index 7d4d43533d..ecfef4c06d 100644 --- a/src/plugin/ComponentManager.h +++ b/src/plugin/ComponentManager.h @@ -250,7 +250,7 @@ void ComponentManager::RegisterComponent(C* component, reporter->FatalError("Component '%s::%s' defined more than once", module.c_str(), cname.c_str()); - DBG_LOG(DBG_PLUGINS, "Registering component %s (tag %s)", + DBG_LOG(zeek::DBG_PLUGINS, "Registering component %s (tag %s)", component->Name().c_str(), component->Tag().AsString().c_str()); components_by_name.insert(std::make_pair(cname, component)); diff --git a/src/plugin/Manager.cc b/src/plugin/Manager.cc index eaded40590..be46a246b6 100644 --- a/src/plugin/Manager.cc +++ b/src/plugin/Manager.cc @@ -65,7 +65,7 @@ void Manager::SearchDynamicPlugins(const std::string& dir) if ( ! is_dir(dir) ) { - DBG_LOG(DBG_PLUGINS, "Not a valid plugin directory: %s", dir.c_str()); + DBG_LOG(zeek::DBG_PLUGINS, "Not a valid plugin directory: %s", dir.c_str()); return; } @@ -91,14 +91,14 @@ void Manager::SearchDynamicPlugins(const std::string& dir) if ( dynamic_plugins.find(lower_name) != dynamic_plugins.end() ) { - DBG_LOG(DBG_PLUGINS, "Found already known plugin %s in %s, ignoring", name.c_str(), dir.c_str()); + DBG_LOG(zeek::DBG_PLUGINS, "Found already known plugin %s in %s, ignoring", name.c_str(), dir.c_str()); return; } // Record it, so that we can later activate it. dynamic_plugins.insert(std::make_pair(lower_name, dir)); - DBG_LOG(DBG_PLUGINS, "Found plugin %s in %s", name.c_str(), dir.c_str()); + DBG_LOG(zeek::DBG_PLUGINS, "Found plugin %s in %s", name.c_str(), dir.c_str()); return; } @@ -108,7 +108,7 @@ void Manager::SearchDynamicPlugins(const std::string& dir) if ( ! d ) { - DBG_LOG(DBG_PLUGINS, "Cannot open directory %s", dir.c_str()); + DBG_LOG(zeek::DBG_PLUGINS, "Cannot open directory %s", dir.c_str()); return; } @@ -128,7 +128,7 @@ void Manager::SearchDynamicPlugins(const std::string& dir) if( stat(path.c_str(), &st) < 0 ) { - DBG_LOG(DBG_PLUGINS, "Cannot stat %s: %s", path.c_str(), strerror(errno)); + DBG_LOG(zeek::DBG_PLUGINS, "Cannot stat %s: %s", path.c_str(), strerror(errno)); continue; } @@ -172,14 +172,14 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_ std::string dir = m->second + "/"; - DBG_LOG(DBG_PLUGINS, "Activating plugin %s", name.c_str()); + DBG_LOG(zeek::DBG_PLUGINS, "Activating plugin %s", name.c_str()); // Add the "scripts" and "bif" directories to ZEEKPATH. std::string scripts = dir + "scripts"; if ( is_dir(scripts) ) { - DBG_LOG(DBG_PLUGINS, " Adding %s to ZEEKPATH", scripts.c_str()); + DBG_LOG(zeek::DBG_PLUGINS, " Adding %s to ZEEKPATH", scripts.c_str()); add_to_bro_path(scripts); } @@ -192,7 +192,7 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_ if ( is_file(init) ) { - DBG_LOG(DBG_PLUGINS, " Loading %s", init.c_str()); + DBG_LOG(zeek::DBG_PLUGINS, " Loading %s", init.c_str()); warn_if_legacy_script(init); scripts_to_load.push_back(init); break; @@ -206,7 +206,7 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_ if ( is_file(init) ) { - DBG_LOG(DBG_PLUGINS, " Loading %s", init.c_str()); + DBG_LOG(zeek::DBG_PLUGINS, " Loading %s", init.c_str()); warn_if_legacy_script(init); scripts_to_load.push_back(init); break; @@ -219,7 +219,7 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_ if ( is_file(init) ) { - DBG_LOG(DBG_PLUGINS, " Loading %s", init.c_str()); + DBG_LOG(zeek::DBG_PLUGINS, " Loading %s", init.c_str()); warn_if_legacy_script(init); scripts_to_load.push_back(init); break; @@ -230,7 +230,7 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_ string dypattern = dir + "/lib/*." + HOST_ARCHITECTURE + DYNAMIC_PLUGIN_SUFFIX; - DBG_LOG(DBG_PLUGINS, " Searching for shared libraries %s", dypattern.c_str()); + DBG_LOG(zeek::DBG_PLUGINS, " Searching for shared libraries %s", dypattern.c_str()); glob_t gl; @@ -256,7 +256,7 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_ current_plugin->SetDynamic(true); current_plugin->DoConfigure(); - DBG_LOG(DBG_PLUGINS, " InitialzingComponents"); + DBG_LOG(zeek::DBG_PLUGINS, " InitialzingComponents"); current_plugin->InitializeComponents(); plugins_by_path.insert(std::make_pair(normalize_path(dir), current_plugin)); @@ -276,7 +276,7 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_ current_sopath = nullptr; current_plugin = nullptr; - DBG_LOG(DBG_PLUGINS, " Loaded %s", path); + DBG_LOG(zeek::DBG_PLUGINS, " Loaded %s", path); } globfree(&gl); @@ -284,7 +284,7 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_ else { - DBG_LOG(DBG_PLUGINS, " No shared library found"); + DBG_LOG(zeek::DBG_PLUGINS, " No shared library found"); } // Mark this plugin as activated by clearing the path. @@ -573,7 +573,7 @@ void Manager::DisableHook(zeek::plugin::HookType hook, Plugin* plugin) void Manager::RequestEvent(EventHandlerPtr handler, Plugin* plugin) { - DBG_LOG(DBG_PLUGINS, "Plugin %s requested event %s", + DBG_LOG(zeek::DBG_PLUGINS, "Plugin %s requested event %s", plugin->Name().c_str(), handler->Name()); handler->SetGenerateAlways(); } diff --git a/src/scan.l b/src/scan.l index b171ed85c2..af50f336d0 100644 --- a/src/scan.l +++ b/src/scan.l @@ -650,7 +650,7 @@ static int load_files(const char* orig_file) zeekygen_mgr->Script(file_path); - DBG_LOG(DBG_SCRIPTS, "Loading %s", file_path.c_str()); + DBG_LOG(zeek::DBG_SCRIPTS, "Loading %s", file_path.c_str()); // "orig_file", could be an alias for yytext, which is ephemeral // and will be zapped after the yy_switch_to_buffer() below. @@ -1064,6 +1064,6 @@ bool ScannedFile::AlreadyScanned() const break; } - DBG_LOG(DBG_SCRIPTS, "AlreadyScanned result (%d) %s", rval, canonical_path.data()); + DBG_LOG(zeek::DBG_SCRIPTS, "AlreadyScanned result (%d) %s", rval, canonical_path.data()); return rval; } diff --git a/src/supervisor/Supervisor.cc b/src/supervisor/Supervisor.cc index c6f0b16ed8..c7e440ffd4 100644 --- a/src/supervisor/Supervisor.cc +++ b/src/supervisor/Supervisor.cc @@ -217,7 +217,7 @@ Supervisor::Supervisor(Supervisor::Config cfg, SupervisorStemHandle sh) stem_stderr.prefix = "[supervisor:STDERR] "; stem_stderr.stream = stderr; - DBG_LOG(DBG_SUPERVISOR, "forked stem process %d", stem_pid); + DBG_LOG(zeek::DBG_SUPERVISOR, "forked stem process %d", stem_pid); setsignal(SIGCHLD, supervisor_signal_handler); int status; @@ -251,14 +251,14 @@ Supervisor::~Supervisor() if ( ! stem_pid ) { - DBG_LOG(DBG_SUPERVISOR, "shutdown, stem process already exited"); + DBG_LOG(zeek::DBG_SUPERVISOR, "shutdown, stem process already exited"); return; } iosource_mgr->UnregisterFd(signal_flare.FD(), this); iosource_mgr->UnregisterFd(stem_pipe->InFD(), this); - DBG_LOG(DBG_SUPERVISOR, "shutdown, killing stem process %d", stem_pid); + DBG_LOG(zeek::DBG_SUPERVISOR, "shutdown, killing stem process %d", stem_pid); auto kill_res = kill(stem_pid, SIGTERM); @@ -318,12 +318,12 @@ void Supervisor::ReapStem() if ( WIFEXITED(status) ) { - DBG_LOG(DBG_SUPERVISOR, "stem process exited with status %d", + DBG_LOG(zeek::DBG_SUPERVISOR, "stem process exited with status %d", WEXITSTATUS(status)); } else if ( WIFSIGNALED(status) ) { - DBG_LOG(DBG_SUPERVISOR, "stem process terminated by signal %d", + DBG_LOG(zeek::DBG_SUPERVISOR, "stem process terminated by signal %d", WTERMSIG(status)); } else @@ -384,7 +384,7 @@ void Supervisor::HandleChildSignal() { if ( last_signal >= 0 ) { - DBG_LOG(DBG_SUPERVISOR, "Supervisor received signal %d", last_signal); + DBG_LOG(zeek::DBG_SUPERVISOR, "Supervisor received signal %d", last_signal); last_signal = -1; } @@ -394,7 +394,7 @@ void Supervisor::HandleChildSignal() { ReapStem(); - DBG_LOG(DBG_SUPERVISOR, "Supervisor processed child signal %s", + DBG_LOG(zeek::DBG_SUPERVISOR, "Supervisor processed child signal %s", stem_pid ? "(spurious)" : ""); } @@ -471,7 +471,7 @@ void Supervisor::HandleChildSignal() "redirected stderr pipe"); } - DBG_LOG(DBG_SUPERVISOR, "stem process revived, new pid: %d", stem_pid); + DBG_LOG(zeek::DBG_SUPERVISOR, "stem process revived, new pid: %d", stem_pid); // Parent supervisor process resends node configurations to recreate // the desired process hierarchy. @@ -591,7 +591,7 @@ size_t Supervisor::ProcessMessages() for ( auto& msg : msgs ) { - DBG_LOG(DBG_SUPERVISOR, "read msg from Stem: %s", msg.data()); + DBG_LOG(zeek::DBG_SUPERVISOR, "read msg from Stem: %s", msg.data()); std::vector msg_tokens; tokenize_string(msg, " ", &msg_tokens); const auto& type = msg_tokens[0]; diff --git a/src/threading/BasicThread.cc b/src/threading/BasicThread.cc index 0c7a6ead3b..c6bc01f39c 100644 --- a/src/threading/BasicThread.cc +++ b/src/threading/BasicThread.cc @@ -96,7 +96,7 @@ void BasicThread::Start() thread = std::thread(&BasicThread::launcher, this); - DBG_LOG(DBG_THREADING, "Started thread %s", name); + DBG_LOG(zeek::DBG_THREADING, "Started thread %s", name); OnStart(); } @@ -109,7 +109,7 @@ void BasicThread::SignalStop() if ( terminating ) return; - DBG_LOG(DBG_THREADING, "Signaling thread %s to terminate ...", name); + DBG_LOG(zeek::DBG_THREADING, "Signaling thread %s to terminate ...", name); OnSignalStop(); } @@ -119,7 +119,7 @@ void BasicThread::WaitForStop() if ( ! started ) return; - DBG_LOG(DBG_THREADING, "Waiting for thread %s to terminate and process last queue items...", name); + DBG_LOG(zeek::DBG_THREADING, "Waiting for thread %s to terminate and process last queue items...", name); OnWaitForStop(); @@ -145,7 +145,7 @@ void BasicThread::Join() zeek::reporter->FatalError("Failure joining thread %s with error %s", name, e.what()); } - DBG_LOG(DBG_THREADING, "Joined with thread %s", name); + DBG_LOG(zeek::DBG_THREADING, "Joined with thread %s", name); } void BasicThread::Kill() @@ -160,7 +160,7 @@ void BasicThread::Kill() void BasicThread::Done() { - DBG_LOG(DBG_THREADING, "Thread %s has finished", name); + DBG_LOG(zeek::DBG_THREADING, "Thread %s has finished", name); terminating = true; killed = true; diff --git a/src/threading/Manager.cc b/src/threading/Manager.cc index 2963c0a47d..8591006723 100644 --- a/src/threading/Manager.cc +++ b/src/threading/Manager.cc @@ -21,7 +21,7 @@ void HeartbeatTimer::Dispatch(double t, bool is_expire) Manager::Manager() { - DBG_LOG(DBG_THREADING, "Creating thread manager ..."); + DBG_LOG(zeek::DBG_THREADING, "Creating thread manager ..."); did_process = true; next_beat = 0; @@ -36,7 +36,7 @@ Manager::~Manager() void Manager::Terminate() { - DBG_LOG(DBG_THREADING, "Terminating thread manager ..."); + DBG_LOG(zeek::DBG_THREADING, "Terminating thread manager ..."); terminating = true; // First process remaining thread output for the message threads. @@ -64,7 +64,7 @@ void Manager::Terminate() void Manager::AddThread(BasicThread* thread) { - DBG_LOG(DBG_THREADING, "Adding thread %s ...", thread->Name()); + DBG_LOG(zeek::DBG_THREADING, "Adding thread %s ...", thread->Name()); all_threads.push_back(thread); if ( ! heartbeat_timer_running ) @@ -73,13 +73,13 @@ void Manager::AddThread(BasicThread* thread) void Manager::AddMsgThread(MsgThread* thread) { - DBG_LOG(DBG_THREADING, "%s is a MsgThread ...", thread->Name()); + DBG_LOG(zeek::DBG_THREADING, "%s is a MsgThread ...", thread->Name()); msg_threads.push_back(thread); } void Manager::KillThreads() { - DBG_LOG(DBG_THREADING, "Killing threads ..."); + DBG_LOG(zeek::DBG_THREADING, "Killing threads ..."); for ( all_thread_list::iterator i = all_threads.begin(); i != all_threads.end(); i++ ) (*i)->Kill(); @@ -87,7 +87,7 @@ void Manager::KillThreads() void Manager::KillThread(BasicThread* thread) { - DBG_LOG(DBG_THREADING, "Killing thread %s ...", thread->Name()); + DBG_LOG(zeek::DBG_THREADING, "Killing thread %s ...", thread->Name()); thread->Kill(); } @@ -144,7 +144,7 @@ bool Manager::SendEvent(MsgThread* thread, const std::string& name, const int nu } #ifdef DEBUG - DBG_LOG(DBG_INPUT, "Thread %s: SendEvent for event %s with %d vals", + DBG_LOG(zeek::DBG_INPUT, "Thread %s: SendEvent for event %s with %d vals", thread->Name(), name.c_str(), num_vals); #endif diff --git a/src/threading/MsgThread.cc b/src/threading/MsgThread.cc index 4f22dbe162..ce1004b0f5 100644 --- a/src/threading/MsgThread.cc +++ b/src/threading/MsgThread.cc @@ -107,7 +107,7 @@ public: class DebugMessage final : public OutputMessage { public: - DebugMessage(DebugStream arg_stream, MsgThread* thread, const char* arg_msg) + DebugMessage(zeek::DebugStream arg_stream, MsgThread* thread, const char* arg_msg) : OutputMessage("DebugMessage", thread) { stream = arg_stream; msg = copy_string(arg_msg); } @@ -120,7 +120,7 @@ public: } private: const char* msg; - DebugStream stream; + zeek::DebugStream stream; }; #endif @@ -351,7 +351,7 @@ void MsgThread::InternalError(const char* msg) #ifdef DEBUG -void MsgThread::Debug(DebugStream stream, const char* msg) +void MsgThread::Debug(zeek::DebugStream stream, const char* msg) { SendOut(new DebugMessage(stream, this, msg)); } @@ -366,7 +366,7 @@ void MsgThread::SendIn(BasicInputMessage* msg, bool force) return; } - DBG_LOG(DBG_THREADING, "Sending '%s' to %s ...", msg->Name(), Name()); + DBG_LOG(zeek::DBG_THREADING, "Sending '%s' to %s ...", msg->Name(), Name()); queue_in.Put(msg); ++cnt_sent_in; @@ -399,7 +399,7 @@ BasicOutputMessage* MsgThread::RetrieveOut() if ( ! msg ) return nullptr; - DBG_LOG(DBG_THREADING, "Retrieved '%s' from %s", msg->Name(), Name()); + DBG_LOG(zeek::DBG_THREADING, "Retrieved '%s' from %s", msg->Name(), Name()); return msg; } @@ -413,7 +413,7 @@ BasicInputMessage* MsgThread::RetrieveIn() #ifdef DEBUG std::string s = Fmt("Retrieved '%s' in %s", msg->Name(), Name()); - Debug(DBG_THREADING, s.c_str()); + Debug(zeek::DBG_THREADING, s.c_str()); #endif return msg; diff --git a/src/threading/MsgThread.h b/src/threading/MsgThread.h index ede4332a77..4eac9e1d36 100644 --- a/src/threading/MsgThread.h +++ b/src/threading/MsgThread.h @@ -170,7 +170,7 @@ public: * * @param msg The message. It will be prefixed with the thread's name. */ - void Debug(DebugStream stream, const char* msg); + void Debug(zeek::DebugStream stream, const char* msg); #endif /** diff --git a/src/zeekygen/Manager.cc b/src/zeekygen/Manager.cc index a79b818e38..d8fe9db12a 100644 --- a/src/zeekygen/Manager.cc +++ b/src/zeekygen/Manager.cc @@ -24,7 +24,7 @@ static void DbgAndWarn(const char* msg) return; zeek::reporter->Warning("%s", msg); - DBG_LOG(DBG_ZEEKYGEN, "%s", msg); + DBG_LOG(zeek::DBG_ZEEKYGEN, "%s", msg); } static void WarnMissingScript(const char* type, const zeek::detail::ID* id, @@ -145,7 +145,7 @@ void Manager::Script(const string& path) ScriptInfo* info = new ScriptInfo(name, path); scripts.map[name] = info; all_info.push_back(info); - DBG_LOG(DBG_ZEEKYGEN, "Made ScriptInfo %s", name.c_str()); + DBG_LOG(zeek::DBG_ZEEKYGEN, "Made ScriptInfo %s", name.c_str()); if ( ! info->IsPkgLoader() ) return; @@ -162,7 +162,7 @@ void Manager::Script(const string& path) PackageInfo* pkginfo = new PackageInfo(name); packages.map[name] = pkginfo; all_info.push_back(pkginfo); - DBG_LOG(DBG_ZEEKYGEN, "Made PackageInfo %s", name.c_str()); + DBG_LOG(zeek::DBG_ZEEKYGEN, "Made PackageInfo %s", name.c_str()); } void Manager::ScriptDependency(const string& path, const string& dep) @@ -189,7 +189,7 @@ void Manager::ScriptDependency(const string& path, const string& dep) } script_info->AddDependency(depname); - DBG_LOG(DBG_ZEEKYGEN, "Added script dependency %s for %s", + DBG_LOG(zeek::DBG_ZEEKYGEN, "Added script dependency %s for %s", depname.c_str(), name.c_str()); for ( size_t i = 0; i < comment_buffer.size(); ++i ) @@ -213,7 +213,7 @@ void Manager::ModuleUsage(const string& path, const string& module) } script_info->AddModule(module); - DBG_LOG(DBG_ZEEKYGEN, "Added module usage %s in %s", + DBG_LOG(zeek::DBG_ZEEKYGEN, "Added module usage %s in %s", module.c_str(), name.c_str()); } @@ -269,7 +269,7 @@ void Manager::StartType(zeek::detail::IDPtr id) return; } - DBG_LOG(DBG_ZEEKYGEN, "Making IdentifierInfo (incomplete) %s, in %s", + DBG_LOG(zeek::DBG_ZEEKYGEN, "Making IdentifierInfo (incomplete) %s, in %s", id->Name(), script.c_str()); incomplete_type = CreateIdentifierInfo(std::move(id), script_info); } @@ -288,7 +288,7 @@ void Manager::Identifier(zeek::detail::IDPtr id) { if ( incomplete_type->Name() == id->Name() ) { - DBG_LOG(DBG_ZEEKYGEN, "Finished document for type %s", id->Name()); + DBG_LOG(zeek::DBG_ZEEKYGEN, "Finished document for type %s", id->Name()); incomplete_type->CompletedTypeDecl(); incomplete_type = nullptr; return; @@ -318,7 +318,7 @@ void Manager::Identifier(zeek::detail::IDPtr id) { // Internally-created identifier (e.g. file/proto analyzer enum tags). // Handled specially since they don't have a script location. - DBG_LOG(DBG_ZEEKYGEN, "Made internal IdentifierInfo %s", + DBG_LOG(zeek::DBG_ZEEKYGEN, "Made internal IdentifierInfo %s", id->Name()); CreateIdentifierInfo(id, nullptr); return; @@ -333,7 +333,7 @@ void Manager::Identifier(zeek::detail::IDPtr id) return; } - DBG_LOG(DBG_ZEEKYGEN, "Making IdentifierInfo %s, in script %s", + DBG_LOG(zeek::DBG_ZEEKYGEN, "Making IdentifierInfo %s, in script %s", id->Name(), script.c_str()); CreateIdentifierInfo(std::move(id), script_info); } @@ -357,7 +357,7 @@ void Manager::RecordField(const zeek::detail::ID* id, const zeek::TypeDecl* fiel string script = NormalizeScriptPath(path); idd->AddRecordField(field, script, comment_buffer); comment_buffer.clear(); - DBG_LOG(DBG_ZEEKYGEN, "Document record field %s, identifier %s, script %s", + DBG_LOG(zeek::DBG_ZEEKYGEN, "Document record field %s, identifier %s, script %s", field->id, id->Name(), script.c_str()); } @@ -395,7 +395,7 @@ void Manager::Redef(const zeek::detail::ID* id, const string& path, script_info->AddRedef(id_info); comment_buffer.clear(); last_identifier_seen = id_info; - DBG_LOG(DBG_ZEEKYGEN, "Added redef of %s from %s", + DBG_LOG(zeek::DBG_ZEEKYGEN, "Added redef of %s from %s", id->Name(), from_script.c_str()); } diff --git a/src/zeekygen/ScriptInfo.cc b/src/zeekygen/ScriptInfo.cc index 15d35911a9..166e0607f1 100644 --- a/src/zeekygen/ScriptInfo.cc +++ b/src/zeekygen/ScriptInfo.cc @@ -187,7 +187,7 @@ void ScriptInfo::DoInitPostScript() if ( id->IsType() ) { types.push_back(info); - DBG_LOG(DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a type", + DBG_LOG(zeek::DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a type", id->Name(), name.c_str()); continue; } @@ -196,17 +196,17 @@ void ScriptInfo::DoInitPostScript() { switch ( id->GetType()->AsFuncType()->Flavor() ) { case zeek::FUNC_FLAVOR_HOOK: - DBG_LOG(DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a hook", + DBG_LOG(zeek::DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a hook", id->Name(), name.c_str()); hooks.push_back(info); break; case zeek::FUNC_FLAVOR_EVENT: - DBG_LOG(DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a event", + DBG_LOG(zeek::DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a event", id->Name(), name.c_str()); events.push_back(info); break; case zeek::FUNC_FLAVOR_FUNCTION: - DBG_LOG(DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a function", + DBG_LOG(zeek::DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a function", id->Name(), name.c_str()); functions.push_back(info); break; @@ -222,13 +222,13 @@ void ScriptInfo::DoInitPostScript() { if ( id->GetAttr(zeek::detail::ATTR_REDEF) ) { - DBG_LOG(DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a redef_option", + DBG_LOG(zeek::DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a redef_option", id->Name(), name.c_str()); redef_options.push_back(info); } else { - DBG_LOG(DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a constant", + DBG_LOG(zeek::DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a constant", id->Name(), name.c_str()); constants.push_back(info); } @@ -237,7 +237,7 @@ void ScriptInfo::DoInitPostScript() } else if ( id->IsOption() ) { - DBG_LOG(DBG_ZEEKYGEN, "Filter id '%s' in '%s' as an runtime option", + DBG_LOG(zeek::DBG_ZEEKYGEN, "Filter id '%s' in '%s' as an runtime option", id->Name(), name.c_str()); options.push_back(info); @@ -249,7 +249,7 @@ void ScriptInfo::DoInitPostScript() // documentation. continue; - DBG_LOG(DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a state variable", + DBG_LOG(zeek::DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a state variable", id->Name(), name.c_str()); state_vars.push_back(info); } diff --git a/src/zeekygen/Target.cc b/src/zeekygen/Target.cc index 379aec1f2d..710c3ab281 100644 --- a/src/zeekygen/Target.cc +++ b/src/zeekygen/Target.cc @@ -179,7 +179,7 @@ static vector filter_matches(const vector& from, Target* t) if ( t->MatchesPattern(d) ) { - DBG_LOG(DBG_ZEEKYGEN, "'%s' matched pattern for target '%s'", + DBG_LOG(zeek::DBG_ZEEKYGEN, "'%s' matched pattern for target '%s'", d->Name().c_str(), t->Name().c_str()); rval.push_back(d); } @@ -212,7 +212,7 @@ TargetFile::~TargetFile() if ( f ) fclose(f); - DBG_LOG(DBG_ZEEKYGEN, "Wrote out-of-date target '%s'", name.c_str()); + DBG_LOG(zeek::DBG_ZEEKYGEN, "Wrote out-of-date target '%s'", name.c_str()); } @@ -331,7 +331,7 @@ void PackageTarget::DoFindDependencies(const vector& infos) pkg_deps[j]->Name().size())) continue; - DBG_LOG(DBG_ZEEKYGEN, "Script %s associated with package %s", + DBG_LOG(zeek::DBG_ZEEKYGEN, "Script %s associated with package %s", script->Name().c_str(), pkg_deps[j]->Name().c_str()); pkg_manifest[pkg_deps[j]].push_back(script); script_deps.push_back(script); @@ -510,7 +510,7 @@ void ScriptTarget::DoGenerate() const zeek::reporter->Warning("Failed to unlink %s: %s", f.c_str(), strerror(errno)); - DBG_LOG(DBG_ZEEKYGEN, "Delete stale script file %s", f.c_str()); + DBG_LOG(zeek::DBG_ZEEKYGEN, "Delete stale script file %s", f.c_str()); } return;