diff --git a/policy/bro.init b/policy/bro.init index aecc1dbffd..f46808484d 100644 --- a/policy/bro.init +++ b/policy/bro.init @@ -284,6 +284,7 @@ type entropy_test_result: record { # Prototypes of Bro built-in functions. @load strings.bif.bro @load bro.bif.bro +@load reporter.bif.bro @load logging # sic! Not logging.bif. @load logging-ascii @@ -1558,17 +1559,17 @@ const skip_http_data = F &redef; # UDP tunnels. See also: udp_tunnel_port, policy/udp-tunnel.bro. const parse_udp_tunnels = F &redef; -event log_message(t: time, msg: string, location: string) +event reporter_message(t: time, msg: string, location: string) { - print fmt("[script] log_message: %s [%s] [%.6f]", msg, location, t); + print fmt("[script] reporter_message: %s [%s] [%.6f]", msg, location, t); } -event log_warning(t: time, msg: string, location: string) +event reporter_warning(t: time, msg: string, location: string) { - print fmt("[script] log_warning: %s [%s] [%.6f]", msg, location, t); + print fmt("[script] reporter_warning: %s [%s] [%.6f]", msg, location, t); } -event log_error(t: time, msg: string, location: string) +event reporter_error(t: time, msg: string, location: string) { - print fmt("[script] log_error: %s [%s] [%.6f]", msg, location, t); + print fmt("[script] reporter_error: %s [%s] [%.6f]", msg, location, t); } diff --git a/policy/hand-over.bro b/policy/hand-over.bro index 51f3e6fb51..90481c0b1e 100644 --- a/policy/hand-over.bro +++ b/policy/hand-over.bro @@ -46,7 +46,7 @@ event bro_init() { # Disable packet processing. install_src_net_filter(0.0.0.0/0, 0, 100); - # Log::message("waiting for hand-over - packet processing disabled."); + # Reporter::message("waiting for hand-over - packet processing disabled."); } event remote_connection_error(p: event_peer, reason: string) @@ -55,7 +55,7 @@ event remote_connection_error(p: event_peer, reason: string) return; # Seems that the other side in not running. - # Log::error("can't connect for hand-over - starting processing ..."); + # Reporter::error("can't connect for hand-over - starting processing ..."); handover_start_processing(); } @@ -72,7 +72,7 @@ event remote_connection_established(p: event_peer) if ( ! is_handover_peer(p) ) return; - # Log::message(fmt("requesting hand-over from %s:%d", p$host, p$p)); + # Reporter::message(fmt("requesting hand-over from %s:%d", p$host, p$p)); request_remote_events(p, /handover_.*|finished_send_state/); @@ -85,7 +85,7 @@ event remote_connection_established(p: event_peer) # if the remote host is defined as a hand-over host in remote_peers. if ( is_handover_peer(p) ) { - # Log::message(fmt("allowing hand-over from %s:%d", p$host, p$p)); + # Reporter::message(fmt("allowing hand-over from %s:%d", p$host, p$p)); request_remote_events(p, /handover_.*|finished_send_state/); } } @@ -99,7 +99,7 @@ event handover_send_state(p: event_peer) # we will have to try again. if ( ! send_state(p) ) { - # Log::message("can't send state; serialization in progress"); + # Reporter::message("can't send state; serialization in progress"); schedule 5 secs { handover_send_state(p$host, p$p) }; } } @@ -124,7 +124,7 @@ event finished_send_state(p: event_peer) if ( ! is_handover_peer(p) ) return; - #Log::message(fmt("full state received from %s:%d - starting processing ...", + #Reporter::message(fmt("full state received from %s:%d - starting processing ...", # p$host, p$p)); event handover_got_state(p); @@ -139,6 +139,6 @@ event handover_got_state(p: event_peer) if ( ! (is_remote_event() && is_it_us(p$host, p$p)) ) return; - # Log::message(fmt("%s:%d received our state - terminating", p$host, p$p)); + # Reporter::message(fmt("%s:%d received our state - terminating", p$host, p$p)); terminate(); } diff --git a/policy/logging.bro b/policy/logging.bro index 4833e3411e..cdb7cbc575 100644 --- a/policy/logging.bro +++ b/policy/logging.bro @@ -133,11 +133,6 @@ export { global flush: function(id: ID): bool; global add_default_filter: function(id: ID) : bool; global remove_default_filter: function(id: ID) : bool; - - # Defined in logging.bif. - # global message: function(msg: string) : bool; - # global warning: function(msg: string) : bool; - # global error: function(msg: string) : bool; } # We keep a script-level copy of all filters so that we can manipulate them. diff --git a/src/ARP.cc b/src/ARP.cc index 7070b0b13b..cdf0baa170 100644 --- a/src/ARP.cc +++ b/src/ARP.cc @@ -5,7 +5,7 @@ #include "ARP.h" #include "Event.h" -#include "Logger.h" +#include "Reporter.h" ARP_Analyzer::ARP_Analyzer() @@ -219,7 +219,7 @@ void ARP_Analyzer::BadARP(const struct arp_pkthdr* hdr, const char* msg) void ARP_Analyzer::Corrupted(const char* msg) { - bro_logger->Weird(msg); + reporter->Weird(msg); } void ARP_Analyzer::RREvent(EventHandlerPtr e, diff --git a/src/Analyzer.cc b/src/Analyzer.cc index 13192cd28e..c0a29077af 100644 --- a/src/Analyzer.cc +++ b/src/Analyzer.cc @@ -916,12 +916,12 @@ void TransportLayerAnalyzer::Done() void TransportLayerAnalyzer::SetContentsFile(unsigned int /* direction */, BroFile* /* f */) { - bro_logger->Error("analyzer type does not support writing to a contents file"); + reporter->Error("analyzer type does not support writing to a contents file"); } BroFile* TransportLayerAnalyzer::GetContentsFile(unsigned int /* direction */) const { - bro_logger->Error("analyzer type does not support writing to a contents file"); + reporter->Error("analyzer type does not support writing to a contents file"); return 0; } diff --git a/src/Anon.cc b/src/Anon.cc index c9ec674c15..fd309de2b2 100644 --- a/src/Anon.cc +++ b/src/Anon.cc @@ -159,7 +159,7 @@ int AnonymizeIPAddr_A50::PreservePrefix(ipaddr32_t input, int num_bits) if ( ! before_anonymization ) { - bro_logger->Error("prefix perservation specified after anonymization begun"); + reporter->Error("prefix perservation specified after anonymization begun"); return 0; } @@ -206,7 +206,7 @@ AnonymizeIPAddr_A50::Node* AnonymizeIPAddr_A50::new_node_block() int block_size = 1024; Node* block = new Node[block_size]; if ( ! block ) - bro_logger->InternalError("out of memory!"); + reporter->InternalError("out of memory!"); blocks.push_back(block); @@ -258,7 +258,7 @@ ipaddr32_t AnonymizeIPAddr_A50::make_output(ipaddr32_t old_output, int swivel) c AnonymizeIPAddr_A50::Node* AnonymizeIPAddr_A50::make_peer(ipaddr32_t a, Node* n) { if ( a == 0 || a == 0xFFFFFFFFU ) - bro_logger->InternalError("0.0.0.0 and 255.255.255.255 should never get into the tree"); + reporter->InternalError("0.0.0.0 and 255.255.255.255 should never get into the tree"); // Become a peer. // Algorithm: create two nodes, the two peers. Leave orig node as @@ -341,7 +341,7 @@ AnonymizeIPAddr_A50::Node* AnonymizeIPAddr_A50::find_node(ipaddr32_t a) } } - bro_logger->InternalError("out of memory!"); + reporter->InternalError("out of memory!"); return 0; } @@ -389,14 +389,14 @@ ipaddr32_t anonymize_ip(ipaddr32_t ip, enum ip_addr_anonymization_class_t cl) new_ip = ip; else if ( ! ip_anonymizer[method] ) - bro_logger->InternalError("IP anonymizer not initialized"); + reporter->InternalError("IP anonymizer not initialized"); else new_ip = ip_anonymizer[method]->Anonymize(ip); } else - bro_logger->InternalError("invalid IP anonymization method"); + reporter->InternalError("invalid IP anonymization method"); #ifdef LOG_ANONYMIZATION_MAPPING log_anonymization_mapping(ip, new_ip); diff --git a/src/Anon.h b/src/Anon.h index b76851bd95..2f138c36d7 100644 --- a/src/Anon.h +++ b/src/Anon.h @@ -18,7 +18,7 @@ #include using namespace std; -#include "Logger.h" +#include "Reporter.h" #include "net_util.h" // TODO: Anon.h may not be the right place to put these functions ... @@ -53,7 +53,7 @@ public: // Keep the specified prefix unchanged. virtual int PreservePrefix(ipaddr32_t /* input */, int /* num_bits */) { - bro_logger->InternalError("prefix preserving is not supported for the anonymizer"); + reporter->InternalError("prefix preserving is not supported for the anonymizer"); return 0; } diff --git a/src/Base64.cc b/src/Base64.cc index 5907f5bca8..2585debf5e 100644 --- a/src/Base64.cc +++ b/src/Base64.cc @@ -46,7 +46,7 @@ int Base64Decoder::Decode(int len, const char* data, int* pblen, char** pbuf) char* buf; if ( ! pbuf ) - bro_logger->InternalError("nil pointer to decoding result buffer"); + reporter->InternalError("nil pointer to decoding result buffer"); if ( *pbuf ) { diff --git a/src/Base64.h b/src/Base64.h index 4a39374eae..5bf5d4e2bc 100644 --- a/src/Base64.h +++ b/src/Base64.h @@ -46,7 +46,7 @@ public: if ( analyzer ) analyzer->Weird("base64_illegal_encoding", msg); else - bro_logger->Error(msg); + reporter->Error(msg); } protected: diff --git a/src/BroString.cc b/src/BroString.cc index 11097ea64c..8677cd9533 100644 --- a/src/BroString.cc +++ b/src/BroString.cc @@ -11,7 +11,7 @@ #include "BroString.h" #include "Var.h" -#include "Logger.h" +#include "Reporter.h" #ifdef DEBUG #define DEBUG_STR(msg) DBG_LOG(DBG_STRING, msg) @@ -176,9 +176,9 @@ const char* BroString::CheckString() const // Either an embedded NUL, or no final NUL. char* exp_s = Render(); if ( b[n-1] != '\0' ) - bro_logger->Error("string without NUL terminator: \"%s\"", exp_s); + reporter->Error("string without NUL terminator: \"%s\"", exp_s); else - bro_logger->Error("string with embedded NUL: \"%s\"", exp_s); + reporter->Error("string with embedded NUL: \"%s\"", exp_s); delete [] exp_s; return ""; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 316a9cdf33..1a5f096f70 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -137,6 +137,7 @@ set(BIF_SRCS const.bif types.bif strings.bif + reporter.bif ) foreach (bift ${BIF_SRCS}) @@ -326,7 +327,7 @@ set(bro_SRCS IOSource.cc IRC.cc List.cc - Logger.cc + Reporter.cc LogMgr.cc LogWriter.cc LogWriterAscii.cc diff --git a/src/ChunkedIO.cc b/src/ChunkedIO.cc index 0a6c27c391..510947b728 100644 --- a/src/ChunkedIO.cc +++ b/src/ChunkedIO.cc @@ -195,7 +195,7 @@ bool ChunkedIOFd::WriteChunk(Chunk* chunk, bool partial) assert(chunk->len <= BUFFER_SIZE - sizeof(uint32) ); if ( chunk->len == 0 ) - bro_logger->InternalError( "attempt to write 0 bytes chunk"); + reporter->InternalError( "attempt to write 0 bytes chunk"); if ( partial ) chunk->len |= FLAG_PARTIAL; @@ -285,7 +285,7 @@ bool ChunkedIOFd::FlushWriteBuffer() } if ( written == 0 ) - bro_logger->InternalError("written==0"); + reporter->InternalError("written==0"); // Short write. write_pos += written; @@ -906,7 +906,7 @@ bool ChunkedIOSSL::WriteData(char* p, uint32 len, bool* error) return false; } - bro_logger->InternalError("can't be reached"); + reporter->InternalError("can't be reached"); return false; } @@ -1026,7 +1026,7 @@ bool ChunkedIOSSL::ReadData(char* p, uint32 len, bool* error) } // Can't be reached. - bro_logger->InternalError("can't be reached"); + reporter->InternalError("can't be reached"); return false; } diff --git a/src/CompHash.cc b/src/CompHash.cc index 25893c7712..605949b81c 100644 --- a/src/CompHash.cc +++ b/src/CompHash.cc @@ -6,7 +6,7 @@ #include "CompHash.h" #include "Val.h" -#include "Logger.h" +#include "Reporter.h" CompositeHash::CompositeHash(TypeList* composite_type) { @@ -192,7 +192,7 @@ char* CompositeHash::SingleValHash(int type_check, char* kp0, } else { - bro_logger->InternalError("bad index type in CompositeHash::SingleValHash"); + reporter->InternalError("bad index type in CompositeHash::SingleValHash"); return 0; } } @@ -315,7 +315,7 @@ HashKey* CompositeHash::ComputeSingletonHash(const Val* v, int type_check) const if ( v->Type()->Tag() == TYPE_FUNC ) return new HashKey(v); - bro_logger->InternalError("bad index type in CompositeHash::ComputeSingletonHash"); + reporter->InternalError("bad index type in CompositeHash::ComputeSingletonHash"); return 0; case TYPE_INTERNAL_STRING: @@ -325,7 +325,7 @@ HashKey* CompositeHash::ComputeSingletonHash(const Val* v, int type_check) const return 0; default: - bro_logger->InternalError("bad internal type in CompositeHash::ComputeSingletonHash"); + reporter->InternalError("bad internal type in CompositeHash::ComputeSingletonHash"); return 0; } } @@ -400,7 +400,7 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v, } else { - bro_logger->InternalError("bad index type in CompositeHash::CompositeHash"); + reporter->InternalError("bad index type in CompositeHash::CompositeHash"); return 0; } } @@ -523,7 +523,7 @@ ListVal* CompositeHash::RecoverVals(const HashKey* k) const } if ( kp != k_end ) - bro_logger->InternalError("under-ran key in CompositeHash::DescribeKey %ld", k_end - kp); + reporter->InternalError("under-ran key in CompositeHash::DescribeKey %ld", k_end - kp); return l; } @@ -534,7 +534,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey* k, const char* kp0, { // k->Size() == 0 for a single empty string. if ( kp0 >= k_end && k->Size() > 0 ) - bro_logger->InternalError("over-ran key in CompositeHash::RecoverVals"); + reporter->InternalError("over-ran key in CompositeHash::RecoverVals"); TypeTag tag = t->Tag(); InternalTypeTag it = t->InternalType(); @@ -581,7 +581,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey* k, const char* kp0, break; default: - bro_logger->InternalError("bad internal unsigned int in CompositeHash::RecoverOneVal()"); + reporter->InternalError("bad internal unsigned int in CompositeHash::RecoverOneVal()"); pval = 0; break; } @@ -620,7 +620,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey* k, const char* kp0, break; default: - bro_logger->InternalError("bad internal address in CompositeHash::RecoverOneVal()"); + reporter->InternalError("bad internal address in CompositeHash::RecoverOneVal()"); pval = 0; break; } @@ -649,21 +649,21 @@ const char* CompositeHash::RecoverOneVal(const HashKey* k, const char* kp0, Val* v = *kp; if ( ! v || ! v->Type() ) - bro_logger->InternalError("bad aggregate Val in CompositeHash::RecoverOneVal()"); + reporter->InternalError("bad aggregate Val in CompositeHash::RecoverOneVal()"); if ( t->Tag() != TYPE_FUNC && // ### Maybe fix later, but may be fundamentally // un-checkable --US ! same_type(v->Type(), t) ) { - bro_logger->InternalError("inconsistent aggregate Val in CompositeHash::RecoverOneVal()"); + reporter->InternalError("inconsistent aggregate Val in CompositeHash::RecoverOneVal()"); } // ### A crude approximation for now. if ( t->Tag() == TYPE_FUNC && v->Type()->Tag() != TYPE_FUNC ) { - bro_logger->InternalError("inconsistent aggregate Val in CompositeHash::RecoverOneVal()"); + reporter->InternalError("inconsistent aggregate Val in CompositeHash::RecoverOneVal()"); } pval = v->Ref(); @@ -688,7 +688,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey* k, const char* kp0, rt->FieldType(i), v, optional); if ( ! (v || optional) ) { - bro_logger->InternalError("didn't recover expected number of fields from HashKey"); + reporter->InternalError("didn't recover expected number of fields from HashKey"); pval = 0; break; } @@ -708,7 +708,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey* k, const char* kp0, } else { - bro_logger->InternalError("bad index type in CompositeHash::DescribeKey"); + reporter->InternalError("bad index type in CompositeHash::DescribeKey"); } } break; diff --git a/src/CompHash.h b/src/CompHash.h index 8b7b0ebe50..e2f87d240b 100644 --- a/src/CompHash.h +++ b/src/CompHash.h @@ -34,7 +34,7 @@ protected: // Recovers just one Val of possibly many; called from RecoverVals. // Upon return, pval will point to the recovered Val of type t. - // Returns and updated kp for the next Val. Calls bro_logger->InternalError() + // Returns and updated kp for the next Val. Calls reporter->InternalError() // upon errors, so there is no return value for invalid input. const char* RecoverOneVal(const HashKey* k, const char* kp, const char* const k_end, diff --git a/src/Conn.cc b/src/Conn.cc index d031ad9c45..f777a12f57 100644 --- a/src/Conn.cc +++ b/src/Conn.cc @@ -11,7 +11,7 @@ #include "Conn.h" #include "Event.h" #include "Sessions.h" -#include "Logger.h" +#include "Reporter.h" #include "Timer.h" #include "PIA.h" #include "binpac.h" @@ -54,7 +54,7 @@ void ConnectionTimer::Init(Connection* arg_conn, timer_func arg_timer, ConnectionTimer::~ConnectionTimer() { if ( conn->RefCnt() < 1 ) - bro_logger->InternalError("reference count inconsistency in ~ConnectionTimer"); + reporter->InternalError("reference count inconsistency in ~ConnectionTimer"); conn->RemoveTimer(this); Unref(conn); @@ -72,7 +72,7 @@ void ConnectionTimer::Dispatch(double t, int is_expire) (conn->*timer)(t); if ( conn->RefCnt() < 1 ) - bro_logger->InternalError("reference count inconsistency in ConnectionTimer::Dispatch"); + reporter->InternalError("reference count inconsistency in ConnectionTimer::Dispatch"); } IMPLEMENT_SERIAL(ConnectionTimer, SER_CONNECTION_TIMER); @@ -94,7 +94,7 @@ bool ConnectionTimer::DoSerialize(SerialInfo* info) const else if ( timer == timer_func(&Connection::RemoveConnectionTimer) ) type = 4; else - bro_logger->InternalError("unknown function in ConnectionTimer::DoSerialize()"); + reporter->InternalError("unknown function in ConnectionTimer::DoSerialize()"); return conn->Serialize(info) && SERIALIZE(type) && SERIALIZE(do_expire); } @@ -197,7 +197,7 @@ Connection::Connection(NetSessions* s, HashKey* k, double t, const ConnID* id) Connection::~Connection() { if ( ! finished ) - bro_logger->InternalError("Done() not called before destruction of Connection"); + reporter->InternalError("Done() not called before destruction of Connection"); CancelTimers(); @@ -639,7 +639,7 @@ void Connection::ConnectionEvent(EventHandlerPtr f, Analyzer* a, val_list* vl) void Connection::Weird(const char* name, const char* addl) { weird = 1; - bro_logger->Weird(this, name, addl ? addl : ""); + reporter->Weird(this, name, addl ? addl : ""); } void Connection::AddTimer(timer_func timer, double t, int do_expire, @@ -750,7 +750,7 @@ void Connection::Describe(ODesc* d) const break; case TRANSPORT_UNKNOWN: - bro_logger->InternalError("unknown transport in Connction::Describe()"); + reporter->InternalError("unknown transport in Connction::Describe()"); break; } diff --git a/src/ConnCompressor.cc b/src/ConnCompressor.cc index e52a8c763a..e173463205 100644 --- a/src/ConnCompressor.cc +++ b/src/ConnCompressor.cc @@ -663,7 +663,7 @@ const IP_Hdr* ConnCompressor::PendingConnToPacket(const PendingConn* c) // only an IPv4 address. #ifdef BROv6 if ( ! is_v4_addr(c->key.ip1) || ! is_v4_addr(c->key.ip2) ) - bro_logger->InternalError("IPv6 snuck into connection compressor"); + reporter->InternalError("IPv6 snuck into connection compressor"); #endif *(uint32*) &ip->ip_src = to_v4_addr(c->ip1_is_src ? c->key.ip1 : c->key.ip2); @@ -933,7 +933,7 @@ void ConnCompressor::Event(const PendingConn* pending, double t, { // Special case to go through the logger. const char* msg = arg->AsString()->CheckString(); - bro_logger->Weird(conn_val->Ref(), msg); + reporter->Weird(conn_val->Ref(), msg); return; } diff --git a/src/ConnCompressor.h b/src/ConnCompressor.h index f7af860460..342ae07aaa 100644 --- a/src/ConnCompressor.h +++ b/src/ConnCompressor.h @@ -165,7 +165,7 @@ private: void Weird(const PendingConn* pending, double t, const char* msg) { - // This will actually go through the Logger; Event() takes care of + // This will actually go through the Reporter; Event() takes care of // that. Event(pending, t, conn_weird, TCP_ENDPOINT_INACTIVE, 0, TCP_ENDPOINT_INACTIVE, new StringVal(msg)); diff --git a/src/ContentLine.cc b/src/ContentLine.cc index e2c5505c5b..e9f0856462 100644 --- a/src/ContentLine.cc +++ b/src/ContentLine.cc @@ -103,7 +103,7 @@ void ContentLine_Analyzer::DeliverStream(int len, const u_char* data, buf = tmp; if ( ! buf ) - bro_logger->InternalError("out of memory delivering endpoint line"); + reporter->InternalError("out of memory delivering endpoint line"); } DoDeliver(len, data); @@ -125,7 +125,7 @@ void ContentLine_Analyzer::EndpointEOF(bool is_orig) void ContentLine_Analyzer::SetPlainDelivery(int64_t length) { if ( length < 0 ) - bro_logger->InternalError("negative length for plain delivery"); + reporter->InternalError("negative length for plain delivery"); plain_delivery_length = length; } diff --git a/src/DCE_RPC.cc b/src/DCE_RPC.cc index 4cd407d6bd..4e21ecd545 100644 --- a/src/DCE_RPC.cc +++ b/src/DCE_RPC.cc @@ -60,7 +60,7 @@ UUID::UUID(const u_char d[16]) UUID::UUID(const binpac::bytestring& uuid) { if ( uuid.length() != 16 ) - bro_logger->InternalError("UUID length error"); + reporter->InternalError("UUID length error"); memcpy(data, uuid.begin(), 16); s = uuid_to_string(data); } @@ -82,7 +82,7 @@ UUID::UUID(const char* str) } if ( i != 16 ) - bro_logger->InternalError("invalid UUID string: %s", str); + reporter->InternalError("invalid UUID string: %s", str); } typedef map uuid_map_t; diff --git a/src/DNS_Mgr.cc b/src/DNS_Mgr.cc index 1123f9cba4..64dfb025fe 100644 --- a/src/DNS_Mgr.cc +++ b/src/DNS_Mgr.cc @@ -35,7 +35,7 @@ #include "Event.h" #include "Net.h" #include "Var.h" -#include "Logger.h" +#include "Reporter.h" extern "C" { extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); @@ -353,7 +353,7 @@ DNS_Mgr::DNS_Mgr(DNS_MgrMode arg_mode) nb_dns = nb_dns_init(err); if ( ! nb_dns ) - bro_logger->Warning(fmt("problem initializing NB-DNS: %s", err)); + reporter->Warning(fmt("problem initializing NB-DNS: %s", err)); dns_mapping_valid = dns_mapping_unverified = dns_mapping_new_name = dns_mapping_lost_name = dns_mapping_name_changed = @@ -440,7 +440,7 @@ TableVal* DNS_Mgr::LookupHost(const char* name) return d->Addrs()->ConvertToSet(); else { - bro_logger->Warning("no such host:", name); + reporter->Warning("no such host:", name); return empty_addr_set(); } } @@ -453,7 +453,7 @@ TableVal* DNS_Mgr::LookupHost(const char* name) return empty_addr_set(); case DNS_FORCE: - bro_logger->InternalError("can't find DNS entry for %s in cache", name); + reporter->InternalError("can't find DNS entry for %s in cache", name); return 0; case DNS_DEFAULT: @@ -462,7 +462,7 @@ TableVal* DNS_Mgr::LookupHost(const char* name) return LookupHost(name); default: - bro_logger->InternalError("bad mode in DNS_Mgr::LookupHost"); + reporter->InternalError("bad mode in DNS_Mgr::LookupHost"); return 0; } } @@ -483,7 +483,7 @@ Val* DNS_Mgr::LookupAddr(uint32 addr) return d->Host(); else { - bro_logger->Warning("can't resolve IP address:", dotted_addr(addr)); + reporter->Warning("can't resolve IP address:", dotted_addr(addr)); return new StringVal(dotted_addr(addr)); } } @@ -496,7 +496,7 @@ Val* DNS_Mgr::LookupAddr(uint32 addr) return new StringVal(""); case DNS_FORCE: - bro_logger->InternalError("can't find DNS entry for %s in cache", + reporter->InternalError("can't find DNS entry for %s in cache", dotted_addr(addr)); return 0; @@ -506,7 +506,7 @@ Val* DNS_Mgr::LookupAddr(uint32 addr) return LookupAddr(addr); default: - bro_logger->InternalError("bad mode in DNS_Mgr::LookupHost"); + reporter->InternalError("bad mode in DNS_Mgr::LookupHost"); return 0; } } @@ -567,7 +567,7 @@ void DNS_Mgr::Resolve() struct nb_dns_result r; status = nb_dns_activity(nb_dns, &r, err); if ( status < 0 ) - bro_logger->InternalError( + reporter->InternalError( "NB-DNS error in DNS_Mgr::WaitForReplies (%s)", err); else if ( status > 0 ) @@ -745,7 +745,7 @@ void DNS_Mgr::CompareMappings(DNS_Mapping* prev_dm, DNS_Mapping* new_dm) ListVal* new_a = new_dm->Addrs(); if ( ! prev_a || ! new_a ) - bro_logger->InternalError("confused in DNS_Mgr::CompareMappings"); + reporter->InternalError("confused in DNS_Mgr::CompareMappings"); ListVal* prev_delta = AddrListDelta(prev_a, new_a); ListVal* new_delta = AddrListDelta(new_a, prev_a); @@ -815,7 +815,7 @@ void DNS_Mgr::LoadCache(FILE* f) } if ( ! m->NoMapping() ) - bro_logger->InternalError("DNS cache corrupted"); + reporter->InternalError("DNS cache corrupted"); delete m; fclose(f); @@ -935,7 +935,7 @@ void DNS_Mgr::IssueAsyncRequests() if ( ! dr->MakeRequest(nb_dns) ) { - bro_logger->Error("can't issue DNS request"); + reporter->Error("can't issue DNS request"); req->Timeout(); continue; } @@ -1048,7 +1048,7 @@ void DNS_Mgr::Process() int status = nb_dns_activity(nb_dns, &r, err); if ( status < 0 ) - bro_logger->InternalError("NB-DNS error in DNS_Mgr::Process (%s)", err); + reporter->InternalError("NB-DNS error in DNS_Mgr::Process (%s)", err); else if ( status > 0 ) { @@ -1072,7 +1072,7 @@ int DNS_Mgr::AnswerAvailable(int timeout) { int fd = nb_dns_fd(nb_dns); if ( fd < 0 ) - bro_logger->InternalError("nb_dns_fd() failed in DNS_Mgr::WaitForReplies"); + reporter->InternalError("nb_dns_fd() failed in DNS_Mgr::WaitForReplies"); fd_set read_fds; @@ -1089,11 +1089,11 @@ int DNS_Mgr::AnswerAvailable(int timeout) { if ( errno == EINTR ) return -1; - bro_logger->InternalError("problem with DNS select"); + reporter->InternalError("problem with DNS select"); } if ( status > 1 ) - bro_logger->InternalError("strange return from DNS select"); + reporter->InternalError("strange return from DNS select"); return status; } diff --git a/src/DPM.cc b/src/DPM.cc index 09d6e5ed08..69b859a9e1 100644 --- a/src/DPM.cc +++ b/src/DPM.cc @@ -262,7 +262,7 @@ bool DPM::BuildInitialAnalyzerTree(TransportProto proto, Connection* conn, } default: - bro_logger->InternalError("unknown protocol"); + reporter->InternalError("unknown protocol"); } if ( ! root ) diff --git a/src/DbgBreakpoint.cc b/src/DbgBreakpoint.cc index 635bce9ebc..7205a78521 100644 --- a/src/DbgBreakpoint.cc +++ b/src/DbgBreakpoint.cc @@ -204,7 +204,7 @@ bool DbgBreakpoint::Reset() break; } - bro_logger->InternalError("DbgBreakpoint::Reset function incomplete."); + reporter->InternalError("DbgBreakpoint::Reset function incomplete."); // Cannot be reached. return false; @@ -295,7 +295,7 @@ BreakCode DbgBreakpoint::ShouldBreak(Stmt* s) assert(false); default: - bro_logger->InternalError("Invalid breakpoint type in DbgBreakpoint::ShouldBreak"); + reporter->InternalError("Invalid breakpoint type in DbgBreakpoint::ShouldBreak"); } // If we got here, that means that the breakpoint could hit, @@ -312,7 +312,7 @@ BreakCode DbgBreakpoint::ShouldBreak(Stmt* s) BreakCode DbgBreakpoint::ShouldBreak(double t) { if ( kind != BP_TIME ) - bro_logger->InternalError("Calling ShouldBreak(time) on a non-time breakpoint"); + reporter->InternalError("Calling ShouldBreak(time) on a non-time breakpoint"); if ( t < at_time ) return bcNoHit; @@ -353,6 +353,6 @@ void DbgBreakpoint::PrintHitMsg() assert(false); default: - bro_logger->InternalError("Missed a case in DbgBreakpoint::PrintHitMsg\n"); + reporter->InternalError("Missed a case in DbgBreakpoint::PrintHitMsg\n"); } } diff --git a/src/DbgWatch.cc b/src/DbgWatch.cc index 170d54fcb4..74ac26cb73 100644 --- a/src/DbgWatch.cc +++ b/src/DbgWatch.cc @@ -4,17 +4,17 @@ #include "Debug.h" #include "DbgWatch.h" -#include "Logger.h" +#include "Reporter.h" // Support classes DbgWatch::DbgWatch(BroObj* var_to_watch) { - bro_logger->InternalError("DbgWatch unimplemented"); + reporter->InternalError("DbgWatch unimplemented"); } DbgWatch::DbgWatch(Expr* expr_to_watch) { - bro_logger->InternalError("DbgWatch unimplemented"); + reporter->InternalError("DbgWatch unimplemented"); } DbgWatch::~DbgWatch() diff --git a/src/Debug.cc b/src/Debug.cc index 5b3ff429ab..6594b9393d 100644 --- a/src/Debug.cc +++ b/src/Debug.cc @@ -54,7 +54,7 @@ DebuggerState::~DebuggerState() bool StmtLocMapping::StartsAfter(const StmtLocMapping* m2) { if ( ! m2 ) - bro_logger->InternalError("Assertion failed: %s", "m2 != 0"); + reporter->InternalError("Assertion failed: %s", "m2 != 0"); return loc.first_line > m2->loc.first_line || (loc.first_line == m2->loc.first_line && @@ -362,7 +362,7 @@ vector parse_location_string(const string& s) { Filemap* map = g_dbgfilemaps.Lookup(loc_filename); if ( ! map ) - bro_logger->InternalError("Policy file %s should have been loaded\n", + reporter->InternalError("Policy file %s should have been loaded\n", loc_filename); if ( plr.line > how_many_lines_in(loc_filename) ) @@ -603,7 +603,7 @@ int dbg_execute_command(const char* cmd) #endif if ( int(cmd_code) >= num_debug_cmds() ) - bro_logger->InternalError("Assertion failed: %s", "int(cmd_code) < num_debug_cmds()"); + reporter->InternalError("Assertion failed: %s", "int(cmd_code) < num_debug_cmds()"); // Dispatch to the op-specific handler (with args). int retcode = dbg_dispatch_cmd(cmd_code, arguments); @@ -612,7 +612,7 @@ int dbg_execute_command(const char* cmd) const DebugCmdInfo* info = get_debug_cmd_info(cmd_code); if ( ! info ) - bro_logger->InternalError("Assertion failed: %s", "info"); + reporter->InternalError("Assertion failed: %s", "info"); if ( ! info ) return -2; // ### yuck, why -2? @@ -766,7 +766,7 @@ int dbg_handle_debug_input() const Stmt* stmt = curr_frame->GetNextStmt(); if ( ! stmt ) - bro_logger->InternalError("Assertion failed: %s", "stmt != 0"); + reporter->InternalError("Assertion failed: %s", "stmt != 0"); const Location loc = *stmt->GetLocationInfo(); @@ -872,7 +872,7 @@ bool pre_execute_stmt(Stmt* stmt, Frame* f) p = g_debugger_state.breakpoint_map.equal_range(stmt); if ( p.first == p.second ) - bro_logger->InternalError("Breakpoint count nonzero, but no matching breakpoints"); + reporter->InternalError("Breakpoint count nonzero, but no matching breakpoints"); for ( BPMapType::iterator i = p.first; i != p.second; ++i ) { @@ -943,11 +943,11 @@ Val* dbg_eval_expr(const char* expr) (g_frame_stack.size() - 1) - g_debugger_state.curr_frame_idx; if ( ! (frame_idx >= 0 && (unsigned) frame_idx < g_frame_stack.size()) ) - bro_logger->InternalError("Assertion failed: %s", "frame_idx >= 0 && (unsigned) frame_idx < g_frame_stack.size()"); + reporter->InternalError("Assertion failed: %s", "frame_idx >= 0 && (unsigned) frame_idx < g_frame_stack.size()"); Frame* frame = g_frame_stack[frame_idx]; if ( ! (frame) ) - bro_logger->InternalError("Assertion failed: %s", "frame"); + reporter->InternalError("Assertion failed: %s", "frame"); const BroFunc* func = frame->GetFunction(); if ( func ) diff --git a/src/DebugCmds.cc b/src/DebugCmds.cc index 8ebd45fcac..1d3b9dd220 100644 --- a/src/DebugCmds.cc +++ b/src/DebugCmds.cc @@ -194,7 +194,7 @@ static int dbg_backtrace_internal(int start, int end) if ( start < 0 || end < 0 || (unsigned) start >= g_frame_stack.size() || (unsigned) end >= g_frame_stack.size() ) - bro_logger->InternalError("Invalid stack frame index in DbgBacktraceInternal\n"); + reporter->InternalError("Invalid stack frame index in DbgBacktraceInternal\n"); if ( start < end ) { @@ -325,7 +325,7 @@ int dbg_cmd_frame(DebugCmd cmd, const vector& args) // for 'list', 'break', etc. const Stmt* stmt = g_frame_stack[user_frame_number]->GetNextStmt(); if ( ! stmt ) - bro_logger->InternalError("Assertion failed: %s", "stmt != 0"); + reporter->InternalError("Assertion failed: %s", "stmt != 0"); const Location loc = *stmt->GetLocationInfo(); g_debugger_state.last_loc = loc; @@ -365,7 +365,7 @@ int dbg_cmd_break(DebugCmd cmd, const vector& args) Stmt* stmt = g_frame_stack[user_frame_number]->GetNextStmt(); if ( ! stmt ) - bro_logger->InternalError("Assertion failed: %s", "stmt != 0"); + reporter->InternalError("Assertion failed: %s", "stmt != 0"); DbgBreakpoint* bp = new DbgBreakpoint(); bp->SetID(g_debugger_state.NextBPID()); @@ -530,7 +530,7 @@ int dbg_cmd_break_set_state(DebugCmd cmd, const vector& args) break; default: - bro_logger->InternalError("Invalid command in DbgCmdBreakSetState\n"); + reporter->InternalError("Invalid command in DbgCmdBreakSetState\n"); } } diff --git a/src/DebugLogger.cc b/src/DebugLogger.cc index f52966c1f2..326371d981 100644 --- a/src/DebugLogger.cc +++ b/src/DebugLogger.cc @@ -28,7 +28,7 @@ DebugLogger::DebugLogger(const char* filename) file = fopen(filename, "w"); if ( ! file ) - bro_logger->FatalError("can't open '%s' for debugging output.", filename); + reporter->FatalError("can't open '%s' for debugging output.", filename); setvbuf(file, NULL, _IOLBF, 0); } @@ -65,7 +65,7 @@ void DebugLogger::EnableStreams(const char* s) if ( strcasecmp("verbose", tok) == 0 ) verbose = true; else - bro_logger->InternalError("unknown debug stream %s\n", tok); + reporter->InternalError("unknown debug stream %s\n", tok); } tok = strtok(0, ","); diff --git a/src/Desc.cc b/src/Desc.cc index c75261c1ff..e49ec31a2f 100644 --- a/src/Desc.cc +++ b/src/Desc.cc @@ -9,7 +9,7 @@ #include "Desc.h" #include "File.h" -#include "Logger.h" +#include "Reporter.h" #define DEFAULT_SIZE 128 #define SLOP 10 @@ -73,14 +73,14 @@ void ODesc::PushIndent() void ODesc::PopIndent() { if ( --indent_level < 0 ) - bro_logger->InternalError("ODesc::PopIndent underflow"); + reporter->InternalError("ODesc::PopIndent underflow"); NL(); } void ODesc::PopIndentNoNL() { if ( --indent_level < 0 ) - bro_logger->InternalError("ODesc::PopIndent underflow"); + reporter->InternalError("ODesc::PopIndent underflow"); } void ODesc::Add(const char* s, int do_indent) @@ -289,7 +289,7 @@ void ODesc::AddBytesRaw(const void* bytes, unsigned int n) if ( ! write_failed ) // Most likely it's a "disk full" so report // subsequent failures only once. - bro_logger->Error(fmt("error writing to %s: %s", f->Name(), strerror(errno))); + reporter->Error(fmt("error writing to %s: %s", f->Name(), strerror(errno))); write_failed = true; return; @@ -325,5 +325,5 @@ void ODesc::Grow(unsigned int n) void ODesc::OutOfMemory() { - bro_logger->InternalError("out of memory"); + reporter->InternalError("out of memory"); } diff --git a/src/Dict.cc b/src/Dict.cc index 04cf3cab78..6bef17ad3e 100644 --- a/src/Dict.cc +++ b/src/Dict.cc @@ -9,7 +9,7 @@ #endif #include "Dict.h" -#include "Logger.h" +#include "Reporter.h" // If the mean bucket length exceeds the following then Insert() will // increase the size of the hash table. @@ -475,7 +475,7 @@ void Dictionary::StartChangeSize(int new_size) return; if ( tbl2 ) - bro_logger->InternalError("Dictionary::StartChangeSize() tbl2 not NULL"); + reporter->InternalError("Dictionary::StartChangeSize() tbl2 not NULL"); Init2(new_size); @@ -522,7 +522,7 @@ void Dictionary::FinishChangeSize() { // Cheap safety check. if ( num_entries != 0 ) - bro_logger->InternalError( + reporter->InternalError( "Dictionary::FinishChangeSize: num_entries is %d\n", num_entries); diff --git a/src/Event.cc b/src/Event.cc index b7c48f83e1..0ba5b68a21 100644 --- a/src/Event.cc +++ b/src/Event.cc @@ -93,7 +93,7 @@ void EventMgr::QueueEvent(Event* event) void EventMgr::Dispatch() { if ( ! head ) - bro_logger->InternalError("EventMgr underflow"); + reporter->InternalError("EventMgr underflow"); Event* current = head; diff --git a/src/EventRegistry.cc b/src/EventRegistry.cc index 2288d8b509..109ad51a3f 100644 --- a/src/EventRegistry.cc +++ b/src/EventRegistry.cc @@ -91,7 +91,7 @@ void EventRegistry::SetGroup(const char* name, const char* group) { EventHandler* eh = Lookup(name); if ( ! eh ) - bro_logger->InternalError("unknown event handler in SetGroup()"); + reporter->InternalError("unknown event handler in SetGroup()"); eh->SetGroup(group); } diff --git a/src/Expr.cc b/src/Expr.cc index 708cc7d9e1..d748808041 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -383,7 +383,7 @@ bool NameExpr::DoUnserialize(UnserialInfo* info) if ( id ) ::Ref(id); else - bro_logger->Warning("unserialized unknown global name"); + reporter->Warning("unserialized unknown global name"); delete [] name; } @@ -5623,7 +5623,7 @@ int same_expr(const Expr* e1, const Expr* e2) } default: - bro_logger->InternalError("bad tag in same_expr()"); + reporter->InternalError("bad tag in same_expr()"); } return 0; @@ -5643,7 +5643,7 @@ static Expr* make_constant(BroType* t, double d) case TYPE_INTERNAL_DOUBLE: v = new Val(double(d), t->Tag()); break; default: - bro_logger->InternalError("bad type in make_constant()"); + reporter->InternalError("bad type in make_constant()"); } return new ConstExpr(v); diff --git a/src/File.cc b/src/File.cc index 304fc0c088..c8390c9bb5 100644 --- a/src/File.cc +++ b/src/File.cc @@ -30,7 +30,7 @@ #include "Net.h" #include "Serializer.h" #include "Event.h" -#include "Logger.h" +#include "Reporter.h" // Timer which on dispatching rotates the file. class RotateTimer : public Timer { @@ -94,7 +94,7 @@ static int maximize_num_fds() #else struct rlimit rl; if ( getrlimit(RLIMIT_NOFILE, &rl) < 0 ) - bro_logger->InternalError("maximize_num_fds(): getrlimit failed"); + reporter->InternalError("maximize_num_fds(): getrlimit failed"); if ( rl.rlim_max == RLIM_INFINITY ) { @@ -110,7 +110,7 @@ static int maximize_num_fds() rl.rlim_cur = rl.rlim_max; if ( setrlimit(RLIMIT_NOFILE, &rl) < 0 ) - bro_logger->InternalError("maximize_num_fds(): setrlimit failed"); + reporter->InternalError("maximize_num_fds(): setrlimit failed"); return rl.rlim_cur / 2; #endif @@ -151,7 +151,7 @@ BroFile::BroFile(const char* arg_name, const char* arg_access, BroType* arg_t) t = arg_t ? arg_t : base_type(TYPE_STRING); if ( ! Open() ) { - bro_logger->Error(fmt("cannot open %s: %s", name, strerror(errno))); + reporter->Error(fmt("cannot open %s: %s", name, strerror(errno))); is_open = 0; okay_to_manage = 0; } @@ -273,7 +273,7 @@ FILE* BroFile::File() FILE* BroFile::BringIntoCache() { if ( f ) - bro_logger->InternalError("BroFile non-nil non-open file"); + reporter->InternalError("BroFile non-nil non-open file"); if ( num_files_in_cache >= max_files_in_cache ) PurgeCache(); @@ -287,12 +287,12 @@ FILE* BroFile::BringIntoCache() if ( ! f ) { - bro_logger->Error("can't open %s", this); + reporter->Error("can't open %s", this); f = fopen("/dev/null", "w"); if ( ! f ) - bro_logger->InternalError("out of file descriptors"); + reporter->InternalError("out of file descriptors"); okay_to_manage = 0; return f; @@ -302,7 +302,7 @@ FILE* BroFile::BringIntoCache() UpdateFileSize(); if ( fseek(f, position, SEEK_SET) < 0 ) - bro_logger->Error("reopen seek failed", this); + reporter->Error("reopen seek failed", this); InsertAtBeginning(); @@ -315,7 +315,7 @@ FILE* BroFile::Seek(long new_position) return 0; if ( fseek(f, new_position, SEEK_SET) < 0 ) - bro_logger->Error("seek failed", this); + reporter->Error("seek failed", this); return f; } @@ -326,7 +326,7 @@ void BroFile::SetBuf(bool arg_buffered) return; if ( setvbuf(f, NULL, arg_buffered ? _IOFBF : _IOLBF, 0) != 0 ) - bro_logger->Error("setvbuf failed", this); + reporter->Error("setvbuf failed", this); buffered = arg_buffered; } @@ -377,18 +377,18 @@ int BroFile::Close() void BroFile::Suspend() { if ( ! is_in_cache ) - bro_logger->InternalError("BroFile::Suspend() called for non-cached file"); + reporter->InternalError("BroFile::Suspend() called for non-cached file"); if ( ! is_open ) - bro_logger->InternalError("BroFile::Suspend() called for non-open file"); + reporter->InternalError("BroFile::Suspend() called for non-open file"); Unlink(); if ( ! f ) - bro_logger->InternalError("BroFile::Suspend() called for nil file"); + reporter->InternalError("BroFile::Suspend() called for nil file"); if ( (position = ftell(f)) < 0 ) { - bro_logger->Error("ftell failed", this); + reporter->Error("ftell failed", this); position = 0; } @@ -399,7 +399,7 @@ void BroFile::Suspend() void BroFile::PurgeCache() { if ( ! tail ) - bro_logger->InternalError("BroFile purge of empty cache"); + reporter->InternalError("BroFile purge of empty cache"); tail->Suspend(); } @@ -419,13 +419,13 @@ void BroFile::Unlink() Next()->SetPrev(prev); if ( (head || tail) && ! (head && tail) ) - bro_logger->InternalError("BroFile link list botch"); + reporter->InternalError("BroFile link list botch"); is_in_cache = 0; prev = next = 0; if ( --num_files_in_cache < 0 ) - bro_logger->InternalError("BroFile underflow of file cache"); + reporter->InternalError("BroFile underflow of file cache"); } } @@ -445,7 +445,7 @@ void BroFile::InsertAtBeginning() } if ( ++num_files_in_cache > max_files_in_cache ) - bro_logger->InternalError("BroFile overflow of file cache"); + reporter->InternalError("BroFile overflow of file cache"); is_in_cache = 1; } @@ -456,7 +456,7 @@ void BroFile::MoveToBeginning() return; // already at the beginning if ( ! is_in_cache || ! prev ) - bro_logger->InternalError("BroFile inconsistency in MoveToBeginning()"); + reporter->InternalError("BroFile inconsistency in MoveToBeginning()"); Unlink(); InsertAtBeginning(); @@ -643,7 +643,7 @@ void BroFile::InitEncrypt(const char* keyfile) if ( ! key ) { - bro_logger->Error(fmt("can't open key file %s: %s", keyfile, strerror(errno))); + reporter->Error(fmt("can't open key file %s: %s", keyfile, strerror(errno))); Close(); return; } @@ -651,7 +651,7 @@ void BroFile::InitEncrypt(const char* keyfile) pub_key = PEM_read_PUBKEY(key, 0, 0, 0); if ( ! pub_key ) { - bro_logger->Error(fmt("can't read key from %s: %s", keyfile, + reporter->Error(fmt("can't read key from %s: %s", keyfile, ERR_error_string(ERR_get_error(), 0))); Close(); return; @@ -673,7 +673,7 @@ void BroFile::InitEncrypt(const char* keyfile) if ( ! EVP_SealInit(cipher_ctx, cipher_type, &psecret, (int*) &secret_len, iv, &pub_key, 1) ) { - bro_logger->Error(fmt("can't init cipher context for %s: %s", keyfile, + reporter->Error(fmt("can't init cipher context for %s: %s", keyfile, ERR_error_string(ERR_get_error(), 0))); Close(); return; @@ -686,7 +686,7 @@ void BroFile::InitEncrypt(const char* keyfile) fwrite(secret, ntohl(secret_len), 1, f) && fwrite(iv, iv_len, 1, f)) ) { - bro_logger->Error(fmt("can't write header to log file %s: %s", + reporter->Error(fmt("can't write header to log file %s: %s", name, strerror(errno))); Close(); return; @@ -711,7 +711,7 @@ void BroFile::FinishEncrypt() if ( outl && ! fwrite(cipher_buffer, outl, 1, f) ) { - bro_logger->Error(fmt("write error for %s: %s", + reporter->Error(fmt("write error for %s: %s", name, strerror(errno))); return; } @@ -743,7 +743,7 @@ int BroFile::Write(const char* data, int len) if ( ! EVP_SealUpdate(cipher_ctx, cipher_buffer, &outl, (unsigned char*)data, inl) ) { - bro_logger->Error(fmt("encryption error for %s: %s", + reporter->Error(fmt("encryption error for %s: %s", name, ERR_error_string(ERR_get_error(), 0))); Close(); @@ -752,7 +752,7 @@ int BroFile::Write(const char* data, int len) if ( outl && ! fwrite(cipher_buffer, outl, 1, f) ) { - bro_logger->Error(fmt("write error for %s: %s", + reporter->Error(fmt("write error for %s: %s", name, strerror(errno))); Close(); return 0; @@ -800,7 +800,7 @@ void BroFile::UpdateFileSize() struct stat s; if ( fstat(fileno(f), &s) < 0 ) { - bro_logger->Error(fmt("can't stat fd for %s: %s", name, strerror(errno))); + reporter->Error(fmt("can't stat fd for %s: %s", name, strerror(errno))); current_size = 0; return; } diff --git a/src/FileAnalyzer.cc b/src/FileAnalyzer.cc index d4c13dabba..16bf003775 100644 --- a/src/FileAnalyzer.cc +++ b/src/FileAnalyzer.cc @@ -3,7 +3,7 @@ #include #include "FileAnalyzer.h" -#include "Logger.h" +#include "Reporter.h" #ifdef HAVE_LIBMAGIC magic_t File_Analyzer::magic = 0; @@ -76,11 +76,11 @@ void File_Analyzer::InitMagic(magic_t* magic, int flags) *magic = magic_open(flags); if ( ! *magic ) - bro_logger->Error(fmt("can't init libmagic: %s", magic_error(*magic))); + reporter->Error(fmt("can't init libmagic: %s", magic_error(*magic))); else if ( magic_load(*magic, 0) < 0 ) { - bro_logger->Error(fmt("can't load magic file: %s", magic_error(*magic))); + reporter->Error(fmt("can't load magic file: %s", magic_error(*magic))); magic_close(*magic); *magic = 0; } diff --git a/src/FlowSrc.cc b/src/FlowSrc.cc index 0bc48ad5f3..6f31cf2c3e 100644 --- a/src/FlowSrc.cc +++ b/src/FlowSrc.cc @@ -77,7 +77,7 @@ int FlowSocketSrc::ExtractNextPDU() (struct sockaddr*) &from, &fromlen); if ( pdu_len < 0 ) { - bro_logger->Error("problem reading NetFlow data from socket"); + reporter->Error("problem reading NetFlow data from socket"); data = 0; next_timestamp = -1.0; closed = 1; @@ -86,7 +86,7 @@ int FlowSocketSrc::ExtractNextPDU() if ( fromlen != sizeof(from) ) { - bro_logger->Error("malformed NetFlow PDU"); + reporter->Error("malformed NetFlow PDU"); return 0; } @@ -171,7 +171,7 @@ int FlowFileSrc::ExtractNextPDU() if ( pdu_header.pdu_length > NF_MAX_PKT_SIZE ) { - bro_logger->Error("NetFlow packet too long"); + reporter->Error("NetFlow packet too long"); // Safely skip over the too-long PDU. if ( lseek(selectable_fd, pdu_header.pdu_length, SEEK_CUR) < 0 ) diff --git a/src/Frag.cc b/src/Frag.cc index d657e0ce3e..abf68baa14 100644 --- a/src/Frag.cc +++ b/src/Frag.cc @@ -24,7 +24,7 @@ void FragTimer::Dispatch(double t, int /* is_expire */) if ( f ) f->Expire(t); else - bro_logger->InternalError("fragment timer dispatched w/o reassembler"); + reporter->InternalError("fragment timer dispatched w/o reassembler"); } FragReassembler::FragReassembler(NetSessions* arg_s, @@ -209,7 +209,7 @@ void FragReassembler::BlockInserted(DataBlock* /* start_block */) break; if ( b->upper > n ) - bro_logger->InternalError("bad fragment reassembly"); + reporter->InternalError("bad fragment reassembly"); memcpy((void*) &pkt[b->seq], (const void*) b->block, b->upper - b->seq); diff --git a/src/Func.cc b/src/Func.cc index 6d147b62d9..08cf6f4d80 100644 --- a/src/Func.cc +++ b/src/Func.cc @@ -48,7 +48,7 @@ #include "RemoteSerializer.h" #include "Event.h" #include "Traverse.h" -#include "Logger.h" +#include "Reporter.h" extern RETSIGTYPE sig_handler(int signo); @@ -334,7 +334,7 @@ Val* BroFunc::Call(val_list* args, Frame* parent) const (flow != FLOW_RETURN /* we fell off the end */ || ! result /* explicit return with no result */) && ! f->HasDelayed() ) - bro_logger->Warning("non-void function returns without a value:", id->Name()); + reporter->Warning("non-void function returns without a value:", id->Name()); if ( result && g_trace_state.DoTrace() ) { @@ -426,9 +426,9 @@ BuiltinFunc::BuiltinFunc(built_in_func arg_func, const char* arg_name, id = lookup_ID(name, GLOBAL_MODULE_NAME, false); if ( ! id ) - bro_logger->InternalError("built-in function %s missing", name); + reporter->InternalError("built-in function %s missing", name); if ( id->HasVal() ) - bro_logger->InternalError("built-in function %s multiply defined", name); + reporter->InternalError("built-in function %s multiply defined", name); id->SetVal(new Val(this)); } @@ -505,15 +505,17 @@ void builtin_error(const char* msg, BroObj* arg) if ( calling_expr ) calling_expr->Error(msg, arg); else - bro_logger->Error(msg, arg); + reporter->Error(msg, arg); } #include "bro.bif.func_h" #include "logging.bif.func_h" +#include "reporter.bif.func_h" #include "strings.bif.func_h" #include "bro.bif.func_def" #include "logging.bif.func_def" +#include "reporter.bif.func_def" #include "strings.bif.func_def" void init_builtin_funcs() @@ -526,6 +528,7 @@ void init_builtin_funcs() #include "bro.bif.func_init" #include "logging.bif.func_init" +#include "reporter.bif.func_init" #include "strings.bif.func_init" did_builtin_init = true; diff --git a/src/HTTP.cc b/src/HTTP.cc index 1cc5fe1539..a41a0ff6c4 100644 --- a/src/HTTP.cc +++ b/src/HTTP.cc @@ -574,7 +574,7 @@ void HTTP_Message::SubmitData(int len, const char* buf) { if ( buf != (const char*) data_buffer->Bytes() + buffer_offset || buffer_offset + len > buffer_size ) - bro_logger->InternalError("buffer misalignment"); + reporter->InternalError("buffer misalignment"); buffer_offset += len; if ( buffer_offset >= buffer_size ) @@ -622,7 +622,7 @@ void HTTP_Message::SubmitEvent(int event_type, const char* detail) break; default: - bro_logger->InternalError("unrecognized HTTP message event"); + reporter->InternalError("unrecognized HTTP message event"); } MyHTTP_Analyzer()->HTTP_Event(category, detail); @@ -1095,7 +1095,7 @@ int HTTP_Analyzer::HTTP_RequestLine(const char* line, const char* end_of_line) request_method = new StringVal(http_methods[i]); if ( ! ParseRequest(rest, end_of_line) ) - bro_logger->InternalError("HTTP ParseRequest failed"); + reporter->InternalError("HTTP ParseRequest failed"); Conn()->Match(Rule::HTTP_REQUEST, (const u_char*) unescaped_URI->AsString()->Bytes(), diff --git a/src/ID.cc b/src/ID.cc index 27b07b9a43..09c5504f9d 100644 --- a/src/ID.cc +++ b/src/ID.cc @@ -448,7 +448,7 @@ ID* ID::Unserialize(UnserialInfo* info) break; default: - bro_logger->InternalError("unknown type for UnserialInfo::id_policy"); + reporter->InternalError("unknown type for UnserialInfo::id_policy"); } } @@ -552,7 +552,7 @@ bool ID::DoUnserialize(UnserialInfo* info) } if ( installed_tmp && ! global_scope()->Remove(name) ) - bro_logger->InternalError("tmp id missing"); + reporter->InternalError("tmp id missing"); return true; } diff --git a/src/IRC.cc b/src/IRC.cc index 31009b721f..04a07d17a9 100644 --- a/src/IRC.cc +++ b/src/IRC.cc @@ -1178,7 +1178,7 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig) AddSupportAnalyzer(new ZIP_Analyzer(Conn(), true)); AddSupportAnalyzer(new ZIP_Analyzer(Conn(), false)); #else - bro_logger->Error("IRC analyzer lacking libz support"); + reporter->Error("IRC analyzer lacking libz support"); Remove(); #endif } diff --git a/src/LogMgr.cc b/src/LogMgr.cc index 462bbdc27d..dc926c6fed 100644 --- a/src/LogMgr.cc +++ b/src/LogMgr.cc @@ -273,7 +273,7 @@ bool LogVal::Read(SerializationFormat* fmt) } default: - bro_logger->InternalError("unsupported type %s in LogVal::Write", type_name(type)); + reporter->InternalError("unsupported type %s in LogVal::Write", type_name(type)); } return false; @@ -374,7 +374,7 @@ bool LogVal::Write(SerializationFormat* fmt) const } default: - bro_logger->InternalError("unsupported type %s in LogVal::REad", type_name(type)); + reporter->InternalError("unsupported type %s in LogVal::REad", type_name(type)); } return false; @@ -452,7 +452,7 @@ bool LogMgr::CreateStream(EnumVal* id, RecordVal* sval) if ( ! same_type(rtype, BifType::Record::Log::Stream, 0) ) { - bro_logger->Error("sval argument not of right type"); + reporter->Error("sval argument not of right type"); return false; } @@ -468,7 +468,7 @@ bool LogMgr::CreateStream(EnumVal* id, RecordVal* sval) if ( ! LogVal::IsCompatibleType(columns->FieldType(i)) ) { - bro_logger->Error("type of field '%s' is not support for logging output", + reporter->Error("type of field '%s' is not support for logging output", columns->FieldName(i)); return false; @@ -479,7 +479,7 @@ bool LogMgr::CreateStream(EnumVal* id, RecordVal* sval) if ( ! log_attr_present ) { - bro_logger->Error("logged record type does not have any &log attributes"); + reporter->Error("logged record type does not have any &log attributes"); return false; } @@ -493,7 +493,7 @@ bool LogMgr::CreateStream(EnumVal* id, RecordVal* sval) if ( ! etype->IsEvent() ) { - bro_logger->Error("stream event is a function, not an event"); + reporter->Error("stream event is a function, not an event"); return false; } @@ -501,13 +501,13 @@ bool LogMgr::CreateStream(EnumVal* id, RecordVal* sval) if ( args->length() != 1 ) { - bro_logger->Error("stream event must take a single argument"); + reporter->Error("stream event must take a single argument"); return false; } if ( ! same_type((*args)[0], columns) ) { - bro_logger->Error("stream event's argument type does not match column record type"); + reporter->Error("stream event's argument type does not match column record type"); return new Val(0, TYPE_BOOL); } } @@ -627,7 +627,7 @@ bool LogMgr::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt, else { - bro_logger->Error("unsupported field type for log column"); + reporter->Error("unsupported field type for log column"); return false; } } @@ -666,7 +666,7 @@ bool LogMgr::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt, if ( ! filter->fields ) { - bro_logger->Error("out of memory in add_filter"); + reporter->Error("out of memory in add_filter"); return false; } @@ -685,7 +685,7 @@ bool LogMgr::AddFilter(EnumVal* id, RecordVal* fval) if ( ! same_type(rtype, BifType::Record::Log::Filter, 0) ) { - bro_logger->Error("filter argument not of right type"); + reporter->Error("filter argument not of right type"); return false; } @@ -835,7 +835,7 @@ bool LogMgr::Write(EnumVal* id, RecordVal* columns) if ( ! columns ) { - bro_logger->Error("incompatible log record type"); + reporter->Error("incompatible log record type"); return false; } @@ -877,7 +877,7 @@ bool LogMgr::Write(EnumVal* id, RecordVal* columns) if ( ! v->Type()->Tag() == TYPE_STRING ) { - bro_logger->Error("path_func did not return string"); + reporter->Error("path_func did not return string"); Unref(v); return false; } @@ -1061,7 +1061,7 @@ LogVal* LogMgr::ValToLogVal(Val* val, BroType* ty) } default: - bro_logger->InternalError("unsupported type for log_write"); + reporter->InternalError("unsupported type for log_write"); } return lval; @@ -1126,7 +1126,7 @@ LogWriter* LogMgr::CreateWriter(EnumVal* id, EnumVal* writer, string path, { if ( ld->type == BifEnum::Log::WRITER_DEFAULT ) { - bro_logger->Error("unknow writer when creating writer"); + reporter->Error("unknow writer when creating writer"); return 0; } @@ -1285,7 +1285,7 @@ bool LogMgr::Flush(EnumVal* id) void LogMgr::Error(LogWriter* writer, const char* msg) { - bro_logger->Error(fmt("error with writer for %s: %s", + reporter->Error(fmt("error with writer for %s: %s", writer->Path().c_str(), msg)); } diff --git a/src/Login.cc b/src/Login.cc index aa48f1d6bb..0a3849ccd0 100644 --- a/src/Login.cc +++ b/src/Login.cc @@ -115,7 +115,7 @@ void Login_Analyzer::NewLine(bool orig, char* line) } if ( state != LOGIN_STATE_CONFUSED ) - bro_logger->InternalError("bad state in Login_Analyzer::NewLine"); + reporter->InternalError("bad state in Login_Analyzer::NewLine"); // When we're in "confused", we feed each user input line to // login_confused_text, but also scan the text in the @@ -572,7 +572,7 @@ void Login_Analyzer::AddUserText(const char* line) char* Login_Analyzer::PeekUserText() const { if ( num_user_text <= 0 ) - bro_logger->InternalError("underflow in Login_Analyzer::PeekUserText()"); + reporter->InternalError("underflow in Login_Analyzer::PeekUserText()"); return user_text[user_text_first]; } diff --git a/src/MIME.cc b/src/MIME.cc index 7c6a5f8dc4..3fe652d4cc 100644 --- a/src/MIME.cc +++ b/src/MIME.cc @@ -5,7 +5,7 @@ #include "NetVar.h" #include "MIME.h" #include "Event.h" -#include "Logger.h" +#include "Reporter.h" // Here are a few things to do: // @@ -269,7 +269,7 @@ void MIME_Entity::init() MIME_Entity::~MIME_Entity() { if ( ! end_of_data ) - bro_logger->InternalError("EndOfData must be called before delete a MIME_Entity"); + reporter->InternalError("EndOfData must be called before delete a MIME_Entity"); delete current_header_line; Unref(content_type_str); @@ -654,7 +654,7 @@ int MIME_Entity::CheckBoundaryDelimiter(int len, const char* data) { if ( ! multipart_boundary ) { - bro_logger->Warning("boundary delimiter was not specified for a multipart message\n"); + reporter->Warning("boundary delimiter was not specified for a multipart message\n"); DEBUG_MSG("headers of the MIME entity for debug:\n"); DebugPrintHeaders(); return NOT_MULTIPART_BOUNDARY; @@ -800,7 +800,7 @@ void MIME_Entity::DecodeBase64(int len, const char* data) char* prbuf = rbuf; int decoded = base64_decoder->Decode(len, data, &rlen, &prbuf); if ( prbuf != rbuf ) - bro_logger->InternalError("buffer pointer modified in base64 decoding"); + reporter->InternalError("buffer pointer modified in base64 decoding"); DataOctets(rlen, rbuf); len -= decoded; data += decoded; } @@ -809,7 +809,7 @@ void MIME_Entity::DecodeBase64(int len, const char* data) void MIME_Entity::StartDecodeBase64() { if ( base64_decoder ) - bro_logger->InternalError("previous Base64 decoder not released!"); + reporter->InternalError("previous Base64 decoder not released!"); base64_decoder = new Base64Decoder(message->GetAnalyzer()); } @@ -826,7 +826,7 @@ void MIME_Entity::FinishDecodeBase64() if ( base64_decoder->Done(&rlen, &prbuf) ) { // some remaining data if ( prbuf != rbuf ) - bro_logger->InternalError("buffer pointer modified in base64 decoding"); + reporter->InternalError("buffer pointer modified in base64 decoding"); if ( rlen > 0 ) DataOctets(rlen, rbuf); } @@ -840,7 +840,7 @@ int MIME_Entity::GetDataBuffer() int ret = message->RequestBuffer(&data_buf_length, &data_buf_data); if ( ! ret || data_buf_length == 0 || data_buf_data == 0 ) { - // bro_logger->InternalError("cannot get data buffer from MIME_Message", ""); + // reporter->InternalError("cannot get data buffer from MIME_Message", ""); return 0; } @@ -1093,7 +1093,7 @@ void MIME_Mail::SubmitAllHeaders(MIME_HeaderList& hlist) void MIME_Mail::SubmitData(int len, const char* buf) { if ( buf != (char*) data_buffer->Bytes() + buffer_start ) - bro_logger->InternalError("buffer misalignment"); + reporter->InternalError("buffer misalignment"); if ( compute_content_hash ) { @@ -1181,7 +1181,7 @@ void MIME_Mail::SubmitEvent(int event_type, const char* detail) break; default: - bro_logger->InternalError("unrecognized MIME_Mail event"); + reporter->InternalError("unrecognized MIME_Mail event"); } if ( mime_event ) diff --git a/src/MIME.h b/src/MIME.h index 20f2b5d335..b5cdf556ac 100644 --- a/src/MIME.h +++ b/src/MIME.h @@ -193,7 +193,7 @@ public: virtual ~MIME_Message() { if ( ! finished ) - bro_logger->InternalError("Done() must be called before destruction"); + reporter->InternalError("Done() must be called before destruction"); } virtual void Done() { finished = 1; } diff --git a/src/NVT.cc b/src/NVT.cc index c9828c5bfe..ad5e321595 100644 --- a/src/NVT.cc +++ b/src/NVT.cc @@ -38,7 +38,7 @@ void TelnetOption::RecvOption(unsigned int type) { TelnetOption* peer = endp->FindPeerOption(code); if ( ! peer ) - bro_logger->InternalError("option peer missing in TelnetOption::RecvOption"); + reporter->InternalError("option peer missing in TelnetOption::RecvOption"); // WILL/WONT/DO/DONT are messages we've *received* from our peer. switch ( type ) { @@ -83,7 +83,7 @@ void TelnetOption::RecvOption(unsigned int type) break; default: - bro_logger->InternalError("bad option type in TelnetOption::RecvOption"); + reporter->InternalError("bad option type in TelnetOption::RecvOption"); } } @@ -163,7 +163,7 @@ void TelnetEncryptOption::RecvSubOption(u_char* data, int len) (TelnetEncryptOption*) endp->FindPeerOption(code); if ( ! peer ) - bro_logger->InternalError("option peer missing in TelnetEncryptOption::RecvSubOption"); + reporter->InternalError("option peer missing in TelnetEncryptOption::RecvSubOption"); if ( peer->DidRequest() || peer->DoingEncryption() || peer->Endpoint()->AuthenticationHasBeenAccepted() ) @@ -199,7 +199,7 @@ void TelnetAuthenticateOption::RecvSubOption(u_char* data, int len) (TelnetAuthenticateOption*) endp->FindPeerOption(code); if ( ! peer ) - bro_logger->InternalError("option peer missing in TelnetAuthenticateOption::RecvSubOption"); + reporter->InternalError("option peer missing in TelnetAuthenticateOption::RecvSubOption"); if ( ! peer->DidRequestAuthentication() ) InconsistentOption(0); diff --git a/src/Net.cc b/src/Net.cc index 5ac986c7f1..7d538ba67a 100644 --- a/src/Net.cc +++ b/src/Net.cc @@ -26,7 +26,7 @@ #include "Event.h" #include "Timer.h" #include "Var.h" -#include "Logger.h" +#include "Reporter.h" #include "Net.h" #include "Anon.h" #include "PacketSort.h" @@ -119,7 +119,7 @@ RETSIGTYPE watchdog(int /* signo */) pkt_dumper = new PktDumper("watchdog-pkt.pcap"); if ( pkt_dumper->IsError() ) { - bro_logger->Error("watchdog: can't open watchdog-pkt.pcap for writing\n"); + reporter->Error("watchdog: can't open watchdog-pkt.pcap for writing\n"); pkt_dumper = 0; } } @@ -131,7 +131,7 @@ RETSIGTYPE watchdog(int /* signo */) net_get_final_stats(); net_finish(0); - bro_logger->FatalErrorWithCore( + reporter->FatalErrorWithCore( "**watchdog timer expired, t = %d.%06d, start = %d.%06d, dispatched = %d", int_ct, frac_ct, int_pst, frac_pst, current_dispatched); @@ -161,7 +161,7 @@ void net_init(name_list& interfaces, name_list& readfiles, PktFileSrc* ps = new PktFileSrc(readfiles[i], filter); if ( ! ps->IsOpen() ) - bro_logger->FatalError("%s: problem with trace file %s - %s\n", + reporter->FatalError("%s: problem with trace file %s - %s\n", prog, readfiles[i], ps->ErrorMsg()); else { @@ -178,7 +178,7 @@ void net_init(name_list& interfaces, name_list& readfiles, TYPE_FILTER_SECONDARY); if ( ! ps->IsOpen() ) - bro_logger->FatalError("%s: problem with trace file %s - %s\n", + reporter->FatalError("%s: problem with trace file %s - %s\n", prog, readfiles[i], ps->ErrorMsg()); else @@ -196,7 +196,7 @@ void net_init(name_list& interfaces, name_list& readfiles, FlowFileSrc* fs = new FlowFileSrc(flowfiles[i]); if ( ! fs->IsOpen() ) - bro_logger->FatalError("%s: problem with netflow file %s - %s\n", + reporter->FatalError("%s: problem with netflow file %s - %s\n", prog, flowfiles[i], fs->ErrorMsg()); else { @@ -216,7 +216,7 @@ void net_init(name_list& interfaces, name_list& readfiles, ps = new PktInterfaceSrc(interfaces[i], filter); if ( ! ps->IsOpen() ) - bro_logger->FatalError("%s: problem with interface %s - %s\n", + reporter->FatalError("%s: problem with interface %s - %s\n", prog, interfaces[i], ps->ErrorMsg()); else { @@ -231,7 +231,7 @@ void net_init(name_list& interfaces, name_list& readfiles, filter, TYPE_FILTER_SECONDARY); if ( ! ps->IsOpen() ) - bro_logger->Error("%s: problem with interface %s - %s\n", + reporter->Error("%s: problem with interface %s - %s\n", prog, interfaces[i], ps->ErrorMsg()); else @@ -249,7 +249,7 @@ void net_init(name_list& interfaces, name_list& readfiles, FlowSocketSrc* fs = new FlowSocketSrc(netflows[i]); if ( ! fs->IsOpen() ) - bro_logger->Error("%s: problem with netflow socket %s - %s\n", + reporter->Error("%s: problem with netflow socket %s - %s\n", prog, netflows[i], fs->ErrorMsg()); else { @@ -272,12 +272,12 @@ void net_init(name_list& interfaces, name_list& readfiles, // interfaces with different-lengthed media. pkt_dumper = new PktDumper(writefile); if ( pkt_dumper->IsError() ) - bro_logger->FatalError("%s: can't open write file \"%s\" - %s\n", + reporter->FatalError("%s: can't open write file \"%s\" - %s\n", prog, writefile, pkt_dumper->ErrorMsg()); ID* id = global_scope()->Lookup("trace_output_file"); if ( ! id ) - bro_logger->Error("trace_output_file not defined in bro.init"); + reporter->Error("trace_output_file not defined in bro.init"); else id->SetVal(new StringVal(writefile)); } @@ -344,7 +344,7 @@ void net_packet_dispatch(double t, const struct pcap_pkthdr* hdr, // charged against this sample. mgr.Drain(); - sample_logger = new SampleLogger(); + sample_logger = new SampleReporter(); sp = new SegmentProfiler(sample_logger, "load-samp"); } } @@ -537,7 +537,7 @@ void net_get_final_stats() { struct PktSrc::Stats s; ps->Statistics(&s); - bro_logger->Message("%d packets received on interface %s, %d dropped\n", + reporter->Message("%d packets received on interface %s, %d dropped\n", s.received, ps->Interface(), s.dropped); } } @@ -611,7 +611,7 @@ static double suspend_start = 0; void net_suspend_processing() { if ( _processing_suspended == 0 ) - bro_logger->Message("processing suspended"); + reporter->Message("processing suspended"); ++_processing_suspended; } @@ -620,7 +620,7 @@ void net_continue_processing() { if ( _processing_suspended == 1 ) { - bro_logger->Message("processing continued"); + reporter->Message("processing continued"); loop_over_list(pkt_srcs, i) pkt_srcs[i]->ContinueAfterSuspend(); } diff --git a/src/NetVar.cc b/src/NetVar.cc index 52f14d9dab..92893b004d 100644 --- a/src/NetVar.cc +++ b/src/NetVar.cc @@ -259,6 +259,7 @@ StringVal* cmd_line_bpf_filter; #include "types.bif.netvar_def" #include "event.bif.netvar_def" #include "logging.bif.netvar_def" +#include "reporter.bif.netvar_def" void init_event_handlers() { @@ -318,6 +319,7 @@ void init_net_var() #include "const.bif.netvar_init" #include "types.bif.netvar_init" #include "logging.bif.netvar_init" +#include "reporter.bif.netvar_init" conn_id = internal_type("conn_id")->AsRecordType(); endpoint = internal_type("endpoint")->AsRecordType(); diff --git a/src/NetVar.h b/src/NetVar.h index 90df40b6fd..4b65b3bfa5 100644 --- a/src/NetVar.h +++ b/src/NetVar.h @@ -268,5 +268,6 @@ extern void init_net_var(); #include "types.bif.netvar_h" #include "event.bif.netvar_h" #include "logging.bif.netvar_h" +#include "reporter.bif.netvar_h" #endif diff --git a/src/OSFinger.cc b/src/OSFinger.cc index 9ef9764c38..d379d10f0a 100644 --- a/src/OSFinger.cc +++ b/src/OSFinger.cc @@ -87,7 +87,7 @@ void OSFingerprint::collide(uint32 id) if (sig[id].ttl % 32 && sig[id].ttl != 255 && sig[id].ttl % 30) { problems=1; - bro_logger->Warning(fmt("OS fingerprinting: [!] Unusual TTL (%d) for signature '%s %s' (line %d).", + reporter->Warning(fmt("OS fingerprinting: [!] Unusual TTL (%d) for signature '%s %s' (line %d).", sig[id].ttl,sig[id].os,sig[id].desc,sig[id].line)); } @@ -96,7 +96,7 @@ void OSFingerprint::collide(uint32 id) if (!strcmp(sig[i].os,sig[id].os) && !strcmp(sig[i].desc,sig[id].desc)) { problems=1; - bro_logger->Warning(fmt("OS fingerprinting: [!] Duplicate signature name: '%s %s' (line %d and %d).", + reporter->Warning(fmt("OS fingerprinting: [!] Duplicate signature name: '%s %s' (line %d and %d).", sig[i].os,sig[i].desc,sig[i].line,sig[id].line)); } @@ -279,7 +279,7 @@ do_const: if (sig[id].opt[j] ^ sig[i].opt[j]) goto reloop; problems=1; - bro_logger->Warning(fmt("OS fingerprinting: [!] Signature '%s %s' (line %d)\n" + reporter->Warning(fmt("OS fingerprinting: [!] Signature '%s %s' (line %d)\n" " is already covered by '%s %s' (line %d).", sig[id].os,sig[id].desc,sig[id].line,sig[i].os,sig[i].desc, sig[i].line)); diff --git a/src/OSFinger.h b/src/OSFinger.h index 9c30293437..f1f9e492f2 100644 --- a/src/OSFinger.h +++ b/src/OSFinger.h @@ -15,7 +15,7 @@ #include "util.h" #include "Dict.h" -#include "Logger.h" +#include "Reporter.h" // Size limit for size wildcards. #define PACKET_BIG 100 @@ -105,19 +105,19 @@ protected: void Error(const char* msg) { - bro_logger->Error(msg); + reporter->Error(msg); err = true; } void Error(const char* msg, int n) { - bro_logger->Error(msg, n); + reporter->Error(msg, n); err = true; } void Error(const char* msg, const char* s) { - bro_logger->Error(msg, s); + reporter->Error(msg, s); err = true; } diff --git a/src/Obj.cc b/src/Obj.cc index 11a4bbdd9a..666a57ac93 100644 --- a/src/Obj.cc +++ b/src/Obj.cc @@ -98,8 +98,8 @@ void BroObj::Warn(const char* msg, const BroObj* obj2, int pinpoint_only) const { ODesc d; DoMsg(&d, msg, obj2, pinpoint_only); - bro_logger->Warning("%s", d.Description()); - bro_logger->PopLocation(); + reporter->Warning("%s", d.Description()); + reporter->PopLocation(); } void BroObj::Error(const char* msg, const BroObj* obj2, int pinpoint_only) const @@ -109,8 +109,8 @@ void BroObj::Error(const char* msg, const BroObj* obj2, int pinpoint_only) const ODesc d; DoMsg(&d, msg, obj2, pinpoint_only); - bro_logger->Error("%s", d.Description()); - bro_logger->PopLocation(); + reporter->Error("%s", d.Description()); + reporter->PopLocation(); } void BroObj::BadTag(const char* msg, const char* t1, const char* t2) const @@ -126,21 +126,21 @@ void BroObj::BadTag(const char* msg, const char* t1, const char* t2) const ODesc d; DoMsg(&d, out); - bro_logger->FatalError("%s", d.Description()); + reporter->FatalError("%s", d.Description()); } void BroObj::Internal(const char* msg) const { ODesc d; DoMsg(&d, msg); - bro_logger->InternalError("%s", d.Description()); + reporter->InternalError("%s", d.Description()); } void BroObj::InternalWarning(const char* msg) const { ODesc d; DoMsg(&d, msg); - bro_logger->InternalWarning("%s", d.Description()); + reporter->InternalWarning("%s", d.Description()); } void BroObj::AddLocation(ODesc* d) const @@ -197,7 +197,7 @@ void BroObj::DoMsg(ODesc* d, const char s1[], const BroObj* obj2, *obj2->GetLocationInfo() != *GetLocationInfo() ) loc2 = obj2->GetLocationInfo(); - bro_logger->PushLocation(GetLocationInfo(), loc2); + reporter->PushLocation(GetLocationInfo(), loc2); } void BroObj::PinPoint(ODesc* d, const BroObj* obj2, int pinpoint_only) const @@ -244,7 +244,7 @@ void print(const BroObj* obj) void bad_ref(int type) { - bro_logger->InternalError("bad reference count [%d]", type); + reporter->InternalError("bad reference count [%d]", type); abort(); } diff --git a/src/PIA.cc b/src/PIA.cc index cdf45ebb49..32c0b40fc5 100644 --- a/src/PIA.cc +++ b/src/PIA.cc @@ -153,7 +153,7 @@ void PIA_UDP::ActivateAnalyzer(AnalyzerTag::Tag tag, const Rule* rule) void PIA_UDP::DeactivateAnalyzer(AnalyzerTag::Tag tag) { - bro_logger->InternalError("PIA_UDP::Deact not implemented yet"); + reporter->InternalError("PIA_UDP::Deact not implemented yet"); } //// TCP PIA @@ -375,7 +375,7 @@ void PIA_TCP::ActivateAnalyzer(AnalyzerTag::Tag tag, const Rule* rule) void PIA_TCP::DeactivateAnalyzer(AnalyzerTag::Tag tag) { - bro_logger->InternalError("PIA_TCP::Deact not implemented yet"); + reporter->InternalError("PIA_TCP::Deact not implemented yet"); } void PIA_TCP::ReplayStreamBuffer(Analyzer* analyzer) diff --git a/src/POP3.cc b/src/POP3.cc index 3ac2b86c3d..b364541be1 100644 --- a/src/POP3.cc +++ b/src/POP3.cc @@ -15,7 +15,7 @@ #include "POP3.h" #include "Event.h" #include "NVT.h" -#include "Logger.h" +#include "Reporter.h" #undef POP3_CMD_DEF #define POP3_CMD_DEF(cmd) #cmd, @@ -200,7 +200,7 @@ void POP3_Analyzer::ProcessRequest(int length, const char* line) break; default: - bro_logger->InternalError("unexpected authorization state"); + reporter->InternalError("unexpected authorization state"); } delete decoded; @@ -556,7 +556,7 @@ void POP3_Analyzer::ProcessClientCmd() break; default: - bro_logger->InternalError("command not known"); + reporter->InternalError("command not known"); } } @@ -808,7 +808,7 @@ void POP3_Analyzer::BeginData() void POP3_Analyzer::EndData() { if ( ! mail ) - bro_logger->Warning("unmatched end of data"); + reporter->Warning("unmatched end of data"); else { mail->Done(); diff --git a/src/PacketDumper.cc b/src/PacketDumper.cc index 68e29a1f97..d401cd63cb 100644 --- a/src/PacketDumper.cc +++ b/src/PacketDumper.cc @@ -18,7 +18,7 @@ PacketDumper::PacketDumper(pcap_dumper_t* arg_pkt_dump) pkt_dump = arg_pkt_dump; if ( ! pkt_dump ) - bro_logger->InternalError("PacketDumper: nil dump file"); + reporter->InternalError("PacketDumper: nil dump file"); } void PacketDumper::DumpPacket(const struct pcap_pkthdr* hdr, @@ -29,7 +29,7 @@ void PacketDumper::DumpPacket(const struct pcap_pkthdr* hdr, struct pcap_pkthdr h = *hdr; h.caplen = len; if ( h.caplen > hdr->caplen ) - bro_logger->InternalError("bad modified caplen"); + reporter->InternalError("bad modified caplen"); pcap_dump((u_char*) pkt_dump, &h, pkt); } diff --git a/src/PacketSort.cc b/src/PacketSort.cc index 444dbca838..a228c7c0b6 100644 --- a/src/PacketSort.cc +++ b/src/PacketSort.cc @@ -347,7 +347,7 @@ PacketSortElement* PacketSortGlobalPQ::RemoveMin(double timestamp) PacketSortConnPQ* PacketSortGlobalPQ::FindConnPQ(PacketSortElement* e) { if ( ! e->is_tcp ) - bro_logger->InternalError("cannot find a connection for an invalid id"); + reporter->InternalError("cannot find a connection for an invalid id"); PacketSortConnPQ* pq = (PacketSortConnPQ*) conn_pq_table.Lookup(e->key); if ( ! pq ) diff --git a/src/PersistenceSerializer.cc b/src/PersistenceSerializer.cc index dc4019ddbf..3b733986b0 100644 --- a/src/PersistenceSerializer.cc +++ b/src/PersistenceSerializer.cc @@ -13,7 +13,7 @@ #include "RemoteSerializer.h" #include "Conn.h" #include "Event.h" -#include "Logger.h" +#include "Reporter.h" #include "Net.h" class IncrementalWriteTimer : public Timer { @@ -189,7 +189,7 @@ void PersistenceSerializer::RaiseFinishedSendState() vl->append(new PortVal(remote_port)); mgr.QueueEvent(finished_send_state, vl); - bro_logger->Log("Serialization done."); + reporter->Log("Serialization done."); } #endif @@ -213,7 +213,7 @@ void PersistenceSerializer::GotStateAccess(StateAccess* s) void PersistenceSerializer::GotTimer(Timer* s) { - bro_logger->Error("PersistenceSerializer::GotTimer not implemented"); + reporter->Error("PersistenceSerializer::GotTimer not implemented"); } void PersistenceSerializer::GotConnection(Connection* c) @@ -228,7 +228,7 @@ void PersistenceSerializer::GotID(ID* id, Val* /* val */) void PersistenceSerializer::GotPacket(Packet* p) { - bro_logger->Error("PersistenceSerializer::GotPacket not implemented"); + reporter->Error("PersistenceSerializer::GotPacket not implemented"); } bool PersistenceSerializer::LogAccess(const StateAccess& s) @@ -286,7 +286,7 @@ bool PersistenceSerializer::SendState(SourceID peer, bool may_suspend) status->conns = &persistent_conns; status->peer = peer; - bro_logger->Message("Sending state..."); + reporter->Message("Sending state..."); return RunSerialization(status); } @@ -301,7 +301,7 @@ bool PersistenceSerializer::SendConfig(SourceID peer, bool may_suspend) status->ids = global_scope()->GetIDs(); status->peer = peer; - bro_logger->Message("Sending config..."); + reporter->Message("Sending config..."); return RunSerialization(status); } @@ -319,7 +319,7 @@ bool PersistenceSerializer::RunSerialization(SerialStatus* status) { if ( running[i]->type == status->type ) { - bro_logger->Warning("Serialization of type %d already running.", status->type); + reporter->Warning("Serialization of type %d already running.", status->type); return false; } } @@ -381,14 +381,14 @@ bool PersistenceSerializer::RunSerialization(SerialStatus* status) } else - bro_logger->InternalError("unknown suspend state"); + reporter->InternalError("unknown suspend state"); } else if ( cont->Resuming() ) cont->Resume(); else - bro_logger->InternalError("unknown continuation state"); + reporter->InternalError("unknown continuation state"); if ( status->id_cookie ) { @@ -504,7 +504,7 @@ bool PersistenceSerializer::DoIDSerialization(SerialStatus* status, ID* id) break; default: - bro_logger->InternalError("unknown serialization type"); + reporter->InternalError("unknown serialization type"); } return success; @@ -535,7 +535,7 @@ bool PersistenceSerializer::DoConnSerialization(SerialStatus* status, break; default: - bro_logger->InternalError("unknown serialization type"); + reporter->InternalError("unknown serialization type"); } return success; @@ -560,7 +560,7 @@ bool PersistenceSerializer::DoAccessSerialization(SerialStatus* status, break; default: - bro_logger->InternalError("unknown serialization type"); + reporter->InternalError("unknown serialization type"); } return success; diff --git a/src/PktSrc.cc b/src/PktSrc.cc index d35a245e72..050b58b508 100644 --- a/src/PktSrc.cc +++ b/src/PktSrc.cc @@ -400,7 +400,7 @@ void PktSrc::Statistics(Stats* s) else if ( pcap_stats(pd, &pstat) < 0 ) { - bro_logger->Error("problem getting packet filter statistics: %s", + reporter->Error("problem getting packet filter statistics: %s", ErrorMsg()); s->received = s->dropped = s->link = 0; } @@ -463,7 +463,7 @@ PktInterfaceSrc::PktInterfaceSrc(const char* arg_interface, const char* filter, // ### This needs autoconf'ing. #ifdef HAVE_PCAP_INT_H - bro_logger->Message("pcap bufsize = %d\n", ((struct pcap *) pd)->bufsize); + reporter->Message("pcap bufsize = %d\n", ((struct pcap *) pd)->bufsize); #endif #ifdef HAVE_LINUX @@ -486,7 +486,7 @@ PktInterfaceSrc::PktInterfaceSrc(const char* arg_interface, const char* filter, // Couldn't get header size. return; - bro_logger->Message("listening on %s\n", interface); + reporter->Message("listening on %s\n", interface); } else closed = true; @@ -518,7 +518,7 @@ PktFileSrc::PktFileSrc(const char* arg_readfile, const char* filter, selectable_fd = fileno(pcap_file(pd)); if ( selectable_fd < 0 ) - bro_logger->InternalError("OS does not support selectable pcap fd"); + reporter->InternalError("OS does not support selectable pcap fd"); } else closed = true; diff --git a/src/PolicyFile.cc b/src/PolicyFile.cc index b24d885aee..22a6a96cb6 100644 --- a/src/PolicyFile.cc +++ b/src/PolicyFile.cc @@ -16,7 +16,7 @@ using namespace std; #include "Debug.h" #include "util.h" #include "PolicyFile.h" -#include "Logger.h" +#include "Reporter.h" struct PolicyFile { PolicyFile () { filedata = 0; lmtime = 0; } @@ -33,7 +33,7 @@ static PolicyFileMap policy_files; int how_many_lines_in(const char* policy_filename) { if ( ! policy_filename ) - bro_logger->InternalError("NULL value passed to how_many_lines_in\n"); + reporter->InternalError("NULL value passed to how_many_lines_in\n"); FILE* throwaway = fopen(policy_filename, "r"); if ( ! throwaway ) diff --git a/src/PrefixTable.cc b/src/PrefixTable.cc index eb926e7964..03e1495957 100644 --- a/src/PrefixTable.cc +++ b/src/PrefixTable.cc @@ -1,7 +1,7 @@ // $Id: PrefixTable.cc 1016 2005-01-31 21:23:50Z vern $ #include "PrefixTable.h" -#include "Logger.h" +#include "Reporter.h" // IPv4 version. inline static prefix_t* make_prefix(const uint32 addr, int width) @@ -37,7 +37,7 @@ void* PrefixTable::Insert(const_addr_type addr, int width, void* data) Deref_Prefix(prefix); if ( ! node ) - bro_logger->InternalError("Cannot create node in patricia tree"); + reporter->InternalError("Cannot create node in patricia tree"); void* old = node->data; @@ -66,7 +66,7 @@ void* PrefixTable::Insert(const Val* value, void* data) break; default: - bro_logger->InternalError("Wrong index type for PrefixTable"); + reporter->InternalError("Wrong index type for PrefixTable"); return 0; } } @@ -100,7 +100,7 @@ void* PrefixTable::Lookup(const Val* value, bool exact) const break; default: - bro_logger->InternalError("Wrong index type %d for PrefixTable", + reporter->InternalError("Wrong index type %d for PrefixTable", value->Type()->Tag()); return 0; } @@ -138,7 +138,7 @@ void* PrefixTable::Remove(const Val* value) break; default: - bro_logger->InternalError("Wrong index type for PrefixTable"); + reporter->InternalError("Wrong index type for PrefixTable"); return 0; } } diff --git a/src/PriorityQueue.cc b/src/PriorityQueue.cc index 2e5fde970e..d94ccba7d6 100644 --- a/src/PriorityQueue.cc +++ b/src/PriorityQueue.cc @@ -8,7 +8,7 @@ #include #include "PriorityQueue.h" -#include "Logger.h" +#include "Reporter.h" #include "util.h" PriorityQueue::PriorityQueue(int initial_size) @@ -53,7 +53,7 @@ PQ_Element* PriorityQueue::Remove(PQ_Element* e) PQ_Element* e2 = Remove(); if ( e != e2 ) - bro_logger->InternalError("inconsistency in PriorityQueue::Remove"); + reporter->InternalError("inconsistency in PriorityQueue::Remove"); return e2; } diff --git a/src/RE.cc b/src/RE.cc index 724112d36e..af72d84519 100644 --- a/src/RE.cc +++ b/src/RE.cc @@ -114,7 +114,7 @@ int Specific_RE_Matcher::Compile(int lazy) RE_set_input(pattern_text); if ( RE_parse() ) { - bro_logger->Error("error compiling pattern /%s/", pattern_text); + reporter->Error("error compiling pattern /%s/", pattern_text); return 0; } @@ -134,7 +134,7 @@ int Specific_RE_Matcher::Compile(int lazy) int Specific_RE_Matcher::CompileSet(const string_list& set, const int_list& idx) { if ( set.length() != idx.length() ) - bro_logger->InternalError("compileset: lengths of sets differ"); + reporter->InternalError("compileset: lengths of sets differ"); rem = this; @@ -145,7 +145,7 @@ int Specific_RE_Matcher::CompileSet(const string_list& set, const int_list& idx) RE_set_input(set[i]); if ( RE_parse() ) { - bro_logger->Error("error compiling pattern /%s/", set[i]); + reporter->Error("error compiling pattern /%s/", set[i]); return 0; } diff --git a/src/RPC.cc b/src/RPC.cc index 37019339e4..02fb20a436 100644 --- a/src/RPC.cc +++ b/src/RPC.cc @@ -263,7 +263,7 @@ int RPC_Interpreter::DeliverRPC(const u_char* buf, int n, int rpclen, } else if ( n < 0 ) - bro_logger->InternalError("RPC underflow"); + reporter->InternalError("RPC underflow"); return 1; } @@ -473,7 +473,7 @@ bool Contents_RPC::CheckResync(int& len, const u_char*& data, bool orig) if ( resync_toskip != 0 ) // Should never happen. - bro_logger->InternalError("RPC resync: skipping over data failed"); + reporter->InternalError("RPC resync: skipping over data failed"); // Now lets see whether data points to the beginning of a RPC // frame. If the resync processs is successful, we should be @@ -623,7 +623,7 @@ void Contents_RPC::DeliverStream(int len, const u_char* data, bool orig) marker_buf.Init(4,4); if ( ! dummy_p ) - bro_logger->InternalError("inconsistent RPC record marker extraction"); + reporter->InternalError("inconsistent RPC record marker extraction"); last_frag = (marker & 0x80000000) != 0; marker &= 0x7fffffff; diff --git a/src/RSH.cc b/src/RSH.cc index f6b83ddf07..0b833697fd 100644 --- a/src/RSH.cc +++ b/src/RSH.cc @@ -127,7 +127,7 @@ void Contents_Rsh_Analyzer::DoDeliver(int len, const u_char* data) break; default: - bro_logger->InternalError("bad state in Contents_Rsh_Analyzer::DoDeliver"); + reporter->InternalError("bad state in Contents_Rsh_Analyzer::DoDeliver"); break; } } @@ -179,7 +179,7 @@ void Rsh_Analyzer::DeliverStream(int len, const u_char* data, bool orig) void Rsh_Analyzer::ClientUserName(const char* s) { if ( client_name ) - bro_logger->InternalError("multiple rsh client names"); + reporter->InternalError("multiple rsh client names"); client_name = new StringVal(s); } @@ -187,7 +187,7 @@ void Rsh_Analyzer::ClientUserName(const char* s) void Rsh_Analyzer::ServerUserName(const char* s) { if ( username ) - bro_logger->InternalError("multiple rsh initial client names"); + reporter->InternalError("multiple rsh initial client names"); username = new StringVal(s); } diff --git a/src/Reassem.cc b/src/Reassem.cc index 3cd2c7c062..319fcbff3b 100644 --- a/src/Reassem.cc +++ b/src/Reassem.cc @@ -24,7 +24,7 @@ DataBlock::DataBlock(const u_char* data, int size, int arg_seq, block = new u_char[size]; if ( ! block ) - bro_logger->InternalError("out of memory"); + reporter->InternalError("out of memory"); memcpy((void*) block, (const void*) data, size); diff --git a/src/RemoteSerializer.cc b/src/RemoteSerializer.cc index 3df0552890..c4869e4328 100644 --- a/src/RemoteSerializer.cc +++ b/src/RemoteSerializer.cc @@ -186,7 +186,7 @@ #include "File.h" #include "Conn.h" #include "LogMgr.h" -#include "Logger.h" +#include "Reporter.h" extern "C" { #include "setsignal.h" @@ -394,7 +394,7 @@ static bool sendToIO(ChunkedIO* io, ChunkedIO::Chunk* c) { if ( ! io->Write(c) ) { - bro_logger->Warning(fmt("can't send chunk: %s", io->Error())); + reporter->Warning(fmt("can't send chunk: %s", io->Error())); return false; } @@ -406,7 +406,7 @@ static bool sendToIO(ChunkedIO* io, char msg_type, RemoteSerializer::PeerID id, { if ( ! sendCMsg(io, msg_type, id) ) { - bro_logger->Warning(fmt("can't send message of type %d: %s", msg_type, io->Error())); + reporter->Warning(fmt("can't send message of type %d: %s", msg_type, io->Error())); return false; } @@ -421,7 +421,7 @@ static bool sendToIO(ChunkedIO* io, char msg_type, RemoteSerializer::PeerID id, { if ( ! sendCMsg(io, msg_type, id) ) { - bro_logger->Warning(fmt("can't send message of type %d: %s", msg_type, io->Error())); + reporter->Warning(fmt("can't send message of type %d: %s", msg_type, io->Error())); return false; } @@ -664,7 +664,7 @@ void RemoteSerializer::Fork() setpriority(PRIO_PROCESS, 0, 5); child.Run(); - bro_logger->InternalError("cannot be reached"); + reporter->InternalError("cannot be reached"); } } @@ -675,7 +675,7 @@ RemoteSerializer::PeerID RemoteSerializer::Connect(addr_type ip, uint16 port, return true; if ( ! initialized ) - bro_logger->InternalError("remote serializer not initialized"); + reporter->InternalError("remote serializer not initialized"); #ifdef BROv6 if ( ! is_v4_addr(ip) ) @@ -736,13 +736,13 @@ bool RemoteSerializer::RequestSync(PeerID id, bool auth) Peer* peer = LookupPeer(id, true); if ( ! peer ) { - bro_logger->Error(fmt("unknown peer id %d for request sync", int(id))); + reporter->Error(fmt("unknown peer id %d for request sync", int(id))); return false; } if ( peer->phase != Peer::HANDSHAKE ) { - bro_logger->Error(fmt("can't request sync from peer; wrong phase %d", + reporter->Error(fmt("can't request sync from peer; wrong phase %d", peer->phase)); return false; } @@ -763,13 +763,13 @@ bool RemoteSerializer::RequestLogs(PeerID id) Peer* peer = LookupPeer(id, true); if ( ! peer ) { - bro_logger->Error(fmt("unknown peer id %d for request logs", int(id))); + reporter->Error(fmt("unknown peer id %d for request logs", int(id))); return false; } if ( peer->phase != Peer::HANDSHAKE ) { - bro_logger->Error(fmt("can't request logs from peer; wrong phase %d", + reporter->Error(fmt("can't request logs from peer; wrong phase %d", peer->phase)); return false; } @@ -788,13 +788,13 @@ bool RemoteSerializer::RequestEvents(PeerID id, RE_Matcher* pattern) Peer* peer = LookupPeer(id, true); if ( ! peer ) { - bro_logger->Error(fmt("unknown peer id %d for request sync", int(id))); + reporter->Error(fmt("unknown peer id %d for request sync", int(id))); return false; } if ( peer->phase != Peer::HANDSHAKE ) { - bro_logger->Error(fmt("can't request events from peer; wrong phase %d", + reporter->Error(fmt("can't request events from peer; wrong phase %d", peer->phase)); return false; } @@ -855,7 +855,7 @@ bool RemoteSerializer::CompleteHandshake(PeerID id) if ( p->phase != Peer::HANDSHAKE ) { - bro_logger->Error(fmt("can't complete handshake; wrong phase %d", + reporter->Error(fmt("can't complete handshake; wrong phase %d", p->phase)); return false; } @@ -1124,7 +1124,7 @@ bool RemoteSerializer::SendCaptureFilter(PeerID id, const char* filter) if ( peer->phase != Peer::HANDSHAKE ) { - bro_logger->Error(fmt("can't sent capture filter to peer; wrong phase %d", peer->phase)); + reporter->Error(fmt("can't sent capture filter to peer; wrong phase %d", peer->phase)); return false; } @@ -1201,7 +1201,7 @@ bool RemoteSerializer::SendCapabilities(Peer* peer) { if ( peer->phase != Peer::HANDSHAKE ) { - bro_logger->Error(fmt("can't sent capabilties to peer; wrong phase %d", + reporter->Error(fmt("can't sent capabilties to peer; wrong phase %d", peer->phase)); return false; } @@ -1224,7 +1224,7 @@ bool RemoteSerializer::Listen(addr_type ip, uint16 port, bool expect_ssl) return true; if ( ! initialized ) - bro_logger->InternalError("remote serializer not initialized"); + reporter->InternalError("remote serializer not initialized"); #ifdef BROv6 if ( ! is_v4_addr(ip) ) @@ -1546,10 +1546,10 @@ bool RemoteSerializer::Poll(bool may_block) } default: - bro_logger->InternalError("unknown msgstate"); + reporter->InternalError("unknown msgstate"); } - bro_logger->InternalError("cannot be reached"); + reporter->InternalError("cannot be reached"); return false; } @@ -1664,7 +1664,7 @@ bool RemoteSerializer::DoMessage() return true; // keep going } - bro_logger->InternalError("cannot be reached"); + reporter->InternalError("cannot be reached"); return false; } @@ -1955,7 +1955,7 @@ bool RemoteSerializer::ProcessConnected() ID* descr = global_scope()->Lookup("peer_description"); if ( ! descr ) - bro_logger->InternalError("peer_description not defined"); + reporter->InternalError("peer_description not defined"); SerialInfo info(this); SendID(&info, current_peer, *descr); @@ -2138,7 +2138,7 @@ bool RemoteSerializer::HandshakeDone(Peer* peer) else if ( peer->sync_requested & Peer::WE ) peer->send_state = false; else - bro_logger->InternalError("illegal sync_requested value"); + reporter->InternalError("illegal sync_requested value"); } else { @@ -2836,7 +2836,7 @@ void RemoteSerializer::GotStateAccess(StateAccess* s) void RemoteSerializer::GotTimer(Timer* s) { - bro_logger->Error("RemoteSerializer::GotTimer not implemented"); + reporter->Error("RemoteSerializer::GotTimer not implemented"); } void RemoteSerializer::GotPacket(Packet* p) @@ -2940,7 +2940,7 @@ bool RemoteSerializer::SendCMsgToChild(char msg_type, Peer* peer) { if ( ! sendCMsg(io, msg_type, peer ? peer->id : PEER_NONE) ) { - bro_logger->Warning(fmt("can't send message of type %d: %s", + reporter->Warning(fmt("can't send message of type %d: %s", msg_type, io->Error())); return false; } @@ -3013,7 +3013,7 @@ void RemoteSerializer::FatalError(const char* msg) { msg = fmt("fatal error, shutting down communication: %s", msg); Log(LogError, msg); - bro_logger->Error(msg); + reporter->Error(msg); closed = true; kill(child_pid, SIGQUIT); @@ -3054,7 +3054,7 @@ void RemoteSerializer::InternalCommError(const char* msg) #ifdef DEBUG_COMMUNICATION DumpDebugData(); #else - bro_logger->InternalError("%s", msg); + reporter->InternalError("%s", msg); #endif } @@ -3075,7 +3075,7 @@ static ChunkedIO* openDump(const char* file) if ( fd < 0 ) { - bro_logger->Error("cannot open %s: %s\n", file, strerror(errno)); + reporter->Error("cannot open %s: %s\n", file, strerror(errno)); return 0; } @@ -3092,7 +3092,7 @@ void RemoteSerializer::ReadDumpAsMessageType(const char* file) if ( ! io->Read(&chunk, true ) ) { - bro_logger->Error("cannot read %s: %s\n", file, strerror(errno)); + reporter->Error("cannot read %s: %s\n", file, strerror(errno)); return; } @@ -3407,11 +3407,11 @@ bool SocketComm::ProcessParentMessage() } default: - bro_logger->InternalError("unknown msg type %d", parent_msgtype); + reporter->InternalError("unknown msg type %d", parent_msgtype); return true; } - bro_logger->InternalError("cannot be reached"); + reporter->InternalError("cannot be reached"); } case ARGS: @@ -3434,10 +3434,10 @@ bool SocketComm::ProcessParentMessage() } default: - bro_logger->InternalError("unknown msgstate"); + reporter->InternalError("unknown msgstate"); } - bro_logger->InternalError("cannot be reached"); + reporter->InternalError("cannot be reached"); return false; } @@ -3496,7 +3496,7 @@ bool SocketComm::DoParentMessage() peers[j]->io->DumpDebugData(fmt("comm-dump.child.peer.%d", id), false); } #else - bro_logger->InternalError("DEBUG_DUMP support not compiled in"); + reporter->InternalError("DEBUG_DUMP support not compiled in"); #endif return true; } @@ -3556,10 +3556,10 @@ bool SocketComm::DoParentMessage() return ForwardChunkToPeer(); default: - bro_logger->InternalError("ProcessParentMessage: unexpected state"); + reporter->InternalError("ProcessParentMessage: unexpected state"); } - bro_logger->InternalError("cannot be reached"); + reporter->InternalError("cannot be reached"); return false; } @@ -3620,7 +3620,7 @@ bool SocketComm::ProcessListen() bool SocketComm::ProcessParentCompress() { #ifndef HAVE_LIBZ - bro_logger->InternalError("supposed to enable compression but don't have zlib"); + reporter->InternalError("supposed to enable compression but don't have zlib"); return false; #else @@ -3740,7 +3740,7 @@ bool SocketComm::ProcessRemoteMessage(SocketComm::Peer* peer) } default: - bro_logger->InternalError("ProcessRemoteMessage: unexpected state"); + reporter->InternalError("ProcessRemoteMessage: unexpected state"); } assert(false); // Cannot be reached. diff --git a/src/Logger.cc b/src/Reporter.cc similarity index 72% rename from src/Logger.cc rename to src/Reporter.cc index ee24c50678..08e27ae048 100644 --- a/src/Logger.cc +++ b/src/Reporter.cc @@ -1,11 +1,11 @@ -// $Id: Logger.cc 6916 2009-09-24 20:48:36Z vern $ // // See the file "COPYING" in the main distribution directory for copyright. +// #include #include "config.h" -#include "Logger.h" +#include "Reporter.h" #include "Event.h" #include "NetVar.h" #include "Net.h" @@ -19,9 +19,9 @@ int closelog(); } #endif -Logger* bro_logger = 0; +Reporter* reporter = 0; -Logger::Logger() +Reporter::Reporter() { errors = 0; via_events = false; @@ -29,37 +29,37 @@ Logger::Logger() openlog("bro", 0, LOG_LOCAL5); } -Logger::~Logger() +Reporter::~Reporter() { closelog(); } -void Logger::Message(const char* fmt, ...) +void Reporter::Message(const char* fmt, ...) { va_list ap; va_start(ap, fmt); - DoLog("", log_message, stdout, 0, 0, true, true, fmt, ap); + DoLog("", reporter_message, stdout, 0, 0, true, true, fmt, ap); va_end(ap); } -void Logger::Warning(const char* fmt, ...) +void Reporter::Warning(const char* fmt, ...) { va_list ap; va_start(ap, fmt); - DoLog("warning", log_warning, stdout, 0, 0, true, true, fmt, ap); + DoLog("warning", reporter_warning, stdout, 0, 0, true, true, fmt, ap); va_end(ap); } -void Logger::Error(const char* fmt, ...) +void Reporter::Error(const char* fmt, ...) { ++errors; va_list ap; va_start(ap, fmt); - DoLog("error", log_error, stdout, 0, 0, true, true, fmt, ap); + DoLog("error", reporter_error, stdout, 0, 0, true, true, fmt, ap); va_end(ap); } -void Logger::FatalError(const char* fmt, ...) +void Reporter::FatalError(const char* fmt, ...) { va_list ap; va_start(ap, fmt); @@ -73,7 +73,7 @@ void Logger::FatalError(const char* fmt, ...) exit(1); } -void Logger::FatalErrorWithCore(const char* fmt, ...) +void Reporter::FatalErrorWithCore(const char* fmt, ...) { va_list ap; va_start(ap, fmt); @@ -87,7 +87,7 @@ void Logger::FatalErrorWithCore(const char* fmt, ...) abort(); } -void Logger::InternalError(const char* fmt, ...) +void Reporter::InternalError(const char* fmt, ...) { va_list ap; va_start(ap, fmt); @@ -101,15 +101,15 @@ void Logger::InternalError(const char* fmt, ...) abort(); } -void Logger::InternalWarning(const char* fmt, ...) +void Reporter::InternalWarning(const char* fmt, ...) { va_list ap; va_start(ap, fmt); - DoLog("internal warning", log_warning, stdout, 0, 0, true, true, fmt, ap); + DoLog("internal warning", reporter_warning, stdout, 0, 0, true, true, fmt, ap); va_end(ap); } -void Logger::Syslog(const char* fmt, ...) +void Reporter::Syslog(const char* fmt, ...) { if ( reading_traces ) return; @@ -120,7 +120,7 @@ void Logger::Syslog(const char* fmt, ...) va_end(ap); } -void Logger::WeirdHelper(EventHandlerPtr event, Val* conn_val, const char* name, const char* addl, ...) +void Reporter::WeirdHelper(EventHandlerPtr event, Val* conn_val, const char* name, const char* addl, ...) { val_list* vl = new val_list(1); @@ -138,7 +138,7 @@ void Logger::WeirdHelper(EventHandlerPtr event, Val* conn_val, const char* name, delete vl; } -void Logger::WeirdFlowHelper(addr_type orig, addr_type resp, const char* name, ...) +void Reporter::WeirdFlowHelper(addr_type orig, addr_type resp, const char* name, ...) { val_list* vl = new val_list(2); vl->append(new AddrVal(orig)); @@ -152,27 +152,27 @@ void Logger::WeirdFlowHelper(addr_type orig, addr_type resp, const char* name, . delete vl; } -void Logger::Weird(const char* name) +void Reporter::Weird(const char* name) { WeirdHelper(net_weird, 0, name, 0); } -void Logger::Weird(Connection* conn, const char* name, const char* addl) +void Reporter::Weird(Connection* conn, const char* name, const char* addl) { WeirdHelper(conn_weird, conn->BuildConnVal(), name, addl); } -void Logger::Weird(Val* conn_val, const char* name, const char* addl) +void Reporter::Weird(Val* conn_val, const char* name, const char* addl) { WeirdHelper(conn_weird, conn_val, name, addl); } -void Logger::Weird(addr_type orig, addr_type resp, const char* name) +void Reporter::Weird(addr_type orig, addr_type resp, const char* name) { WeirdFlowHelper(orig, resp, name); } -void Logger::DoLog(const char* prefix, EventHandlerPtr event, FILE* out, Connection* conn, val_list* addl, bool location, bool time, const char* fmt, va_list ap) +void Reporter::DoLog(const char* prefix, EventHandlerPtr event, FILE* out, Connection* conn, val_list* addl, bool location, bool time, const char* fmt, va_list ap) { static char tmp[512]; @@ -243,7 +243,7 @@ void Logger::DoLog(const char* prefix, EventHandlerPtr event, FILE* out, Connect buffer = alloced = (char *)realloc(alloced, size); if ( ! buffer ) - FatalError("out of memory in logger"); + FatalError("out of memory in Reporter"); } if ( event && via_events ) @@ -251,7 +251,7 @@ void Logger::DoLog(const char* prefix, EventHandlerPtr event, FILE* out, Connect val_list* vl = new val_list; if ( time ) - vl->append(new Val(network_time, TYPE_TIME)); + vl->append(new Val((bro_start_network_time != 0.0) ? network_time : 0, TYPE_TIME)); vl->append(new StringVal(buffer)); @@ -277,7 +277,7 @@ void Logger::DoLog(const char* prefix, EventHandlerPtr event, FILE* out, Connect { string s = ""; - if ( network_time ) + if ( bro_start_network_time != 0.0 ) { char tmp[32]; snprintf(tmp, 32, "%.6f", network_time); diff --git a/src/Logger.h b/src/Reporter.h similarity index 96% rename from src/Logger.h rename to src/Reporter.h index d206a42e7c..00c414808f 100644 --- a/src/Logger.h +++ b/src/Reporter.h @@ -1,7 +1,7 @@ // See the file "COPYING" in the main distribution directory for copyright. -#ifndef logger_h -#define logger_h +#ifndef REPORTER_H +#define REPORTER_H #include @@ -15,10 +15,10 @@ class Connection; class Location; -class Logger { +class Reporter { public: - Logger(); - ~Logger(); + Reporter(); + ~Reporter(); // Report an informational message, nothing that needs specific // attention. @@ -71,7 +71,7 @@ public: // the location is popped. void PushLocation(const Location* location) { locations.push_back(std::pair(location, 0)); } - + void PushLocation(const Location* loc1, const Location* loc2) { locations.push_back(std::pair(loc1, loc2)); } @@ -91,7 +91,7 @@ private: std::list > locations; }; -extern Logger* bro_logger; +extern Reporter* reporter; #endif diff --git a/src/Rlogin.cc b/src/Rlogin.cc index 322715c056..8404eacca7 100644 --- a/src/Rlogin.cc +++ b/src/Rlogin.cc @@ -192,7 +192,7 @@ void Contents_Rlogin_Analyzer::DoDeliver(int len, const u_char* data) break; default: - bro_logger->InternalError("bad state in Contents_Rlogin_Analyzer::DoDeliver"); + reporter->InternalError("bad state in Contents_Rlogin_Analyzer::DoDeliver"); break; } } @@ -223,7 +223,7 @@ Rlogin_Analyzer::Rlogin_Analyzer(Connection* conn) void Rlogin_Analyzer::ClientUserName(const char* s) { if ( client_name ) - bro_logger->InternalError("multiple rlogin client names"); + reporter->InternalError("multiple rlogin client names"); client_name = new StringVal(s); } diff --git a/src/RuleCondition.cc b/src/RuleCondition.cc index cd9426a01c..78dbee39cd 100644 --- a/src/RuleCondition.cc +++ b/src/RuleCondition.cc @@ -113,7 +113,7 @@ bool RuleConditionPayloadSize::DoMatch(Rule* rule, RuleEndpointState* state, return payload_size >= val; default: - bro_logger->InternalError("unknown comparision type"); + reporter->InternalError("unknown comparision type"); } // Should not be reached @@ -135,7 +135,7 @@ bool RuleConditionEval::DoMatch(Rule* rule, RuleEndpointState* state, { if ( ! id->HasVal() ) { - bro_logger->Error("undefined value"); + reporter->Error("undefined value"); return false; } diff --git a/src/RuleMatcher.cc b/src/RuleMatcher.cc index 591c30a1d6..5c51fd0f35 100644 --- a/src/RuleMatcher.cc +++ b/src/RuleMatcher.cc @@ -10,7 +10,7 @@ #include "NetVar.h" #include "Scope.h" #include "File.h" -#include "Logger.h" +#include "Reporter.h" // FIXME: Things that are not fully implemented/working yet: // @@ -201,7 +201,7 @@ bool RuleMatcher::ReadFiles(const name_list& files) rules_in = search_for_file( files[i], "sig", 0, false); if ( ! rules_in ) { - bro_logger->Error("Can't open signature file", files[i]); + reporter->Error("Can't open signature file", files[i]); return false; } @@ -401,7 +401,7 @@ static inline uint32 getval(const u_char* data, int size) return ntohl(*(uint32*) data); default: - bro_logger->InternalError("illegal HdrTest size"); + reporter->InternalError("illegal HdrTest size"); } // Should not be reached. @@ -514,7 +514,7 @@ RuleEndpointState* RuleMatcher::InitEndpoint(Analyzer* analyzer, default: data = 0; - bro_logger->InternalError("unknown protocol"); + reporter->InternalError("unknown protocol"); } // ### data can be nil here if it's an @@ -543,7 +543,7 @@ RuleEndpointState* RuleMatcher::InitEndpoint(Analyzer* analyzer, DO_MATCH_OR(*h->vals, getval(data + h->offset, h->size), >=); default: - bro_logger->InternalError("unknown comparision type"); + reporter->InternalError("unknown comparision type"); } no_match: @@ -570,7 +570,7 @@ void RuleMatcher::Match(RuleEndpointState* state, Rule::PatternType type, { if ( ! state ) { - bro_logger->Warning("RuleEndpointState not initialized yet."); + reporter->Warning("RuleEndpointState not initialized yet."); return; } diff --git a/src/SMB.cc b/src/SMB.cc index a95e3c8f84..5b3db68db9 100644 --- a/src/SMB.cc +++ b/src/SMB.cc @@ -6,7 +6,7 @@ #include "SMB.h" #include "smb_pac.h" #include "Val.h" -#include "Logger.h" +#include "Reporter.h" namespace { const bool DEBUG_smb_ipc = true; @@ -733,7 +733,7 @@ int SMB_Session::ParseTransaction(int is_orig, int cmd, break; default: - bro_logger->InternalError("command mismatch for ParseTransaction"); + reporter->InternalError("command mismatch for ParseTransaction"); } int ret; diff --git a/src/SMTP.cc b/src/SMTP.cc index 1a2232d015..5822d9d75f 100644 --- a/src/SMTP.cc +++ b/src/SMTP.cc @@ -10,7 +10,7 @@ #include "SMTP.h" #include "Event.h" #include "ContentLine.h" -#include "Logger.h" +#include "Reporter.h" #undef SMTP_CMD_DEF #define SMTP_CMD_DEF(cmd) #cmd, @@ -866,7 +866,7 @@ void SMTP_Analyzer::BeginData() skip_data = 0; // reset the flag at the beginning of the mail if ( mail != 0 ) { - bro_logger->Warning("nested mail transaction"); + reporter->Warning("nested mail transaction"); mail->Done(); delete mail; } @@ -877,7 +877,7 @@ void SMTP_Analyzer::BeginData() void SMTP_Analyzer::EndData() { if ( ! mail ) - bro_logger->Warning("Unmatched end of data"); + reporter->Warning("Unmatched end of data"); else { mail->Done(); diff --git a/src/SSL-binpac.cc b/src/SSL-binpac.cc index 037cc82d04..6cba39853d 100644 --- a/src/SSL-binpac.cc +++ b/src/SSL-binpac.cc @@ -1,6 +1,6 @@ #include "SSL-binpac.h" #include "TCP_Reassembler.h" -#include "Logger.h" +#include "Reporter.h" #include "util.h" @@ -55,7 +55,7 @@ void SSL_Analyzer_binpac::Undelivered(int seq, int len, bool orig) void SSL_Analyzer_binpac::warn_(const char* msg) { - bro_logger->Warning("SSL_Analyzer_binpac: ", msg); + reporter->Warning("SSL_Analyzer_binpac: ", msg); } void SSL_Analyzer_binpac::generate_warnings() diff --git a/src/SSLv2.cc b/src/SSLv2.cc index 6cb1cd3bcb..f699b7bfdb 100644 --- a/src/SSLv2.cc +++ b/src/SSLv2.cc @@ -287,7 +287,7 @@ void SSLv2_Interpreter::NewSSLRecord(SSL_InterpreterEndpoint* s, break; default: - bro_logger->InternalError("SSLv2: unknown state"); + reporter->InternalError("SSLv2: unknown state"); break; } } diff --git a/src/Scope.cc b/src/Scope.cc index ca952d7f47..196937d984 100644 --- a/src/Scope.cc +++ b/src/Scope.cc @@ -7,7 +7,7 @@ #include "ID.h" #include "Val.h" #include "Scope.h" -#include "Logger.h" +#include "Reporter.h" static scope_list scopes; static Scope* top_scope; @@ -28,7 +28,7 @@ Scope::Scope(ID* id) if ( id_type->Tag() == TYPE_ERROR ) return; else if ( id_type->Tag() != TYPE_FUNC ) - bro_logger->InternalError("bad scope id"); + reporter->InternalError("bad scope id"); Ref(id); @@ -129,7 +129,7 @@ ID* lookup_ID(const char* name, const char* curr_module, bool no_global, if ( id ) { if ( need_export && ! id->IsExport() && ! in_debug ) - bro_logger->Error("identifier is not exported:", + reporter->Error("identifier is not exported:", fullname.c_str()); Ref(id); @@ -156,7 +156,7 @@ ID* install_ID(const char* name, const char* module_name, bool is_global, bool is_export) { if ( scopes.length() == 0 && ! is_global ) - bro_logger->InternalError("local identifier in global scope"); + reporter->InternalError("local identifier in global scope"); IDScope scope; if ( is_export || ! module_name || @@ -198,7 +198,7 @@ Scope* pop_scope() { int n = scopes.length() - 1; if ( n < 0 ) - bro_logger->InternalError("scope underflow"); + reporter->InternalError("scope underflow"); scopes.remove_nth(n); Scope* old_top = top_scope; diff --git a/src/SerialObj.cc b/src/SerialObj.cc index c25277b4c0..cddb0b0963 100644 --- a/src/SerialObj.cc +++ b/src/SerialObj.cc @@ -21,7 +21,7 @@ SerialObj* SerialObj::Instantiate(SerialType type) return o; } - bro_logger->Error(fmt("Unknown object type 0x%08x", type)); + reporter->Error(fmt("Unknown object type 0x%08x", type)); return 0; } @@ -31,7 +31,7 @@ const char* SerialObj::ClassName(SerialType type) if ( f != names->end() ) return f->second; - bro_logger->Error(fmt("Unknown object type 0x%08x", type)); + reporter->Error(fmt("Unknown object type 0x%08x", type)); return ""; } @@ -47,7 +47,7 @@ void SerialObj::Register(SerialType type, FactoryFunc f, const char* name) FactoryMap::iterator i = factories->find(type); if ( i != factories->end() ) - bro_logger->InternalError("SerialType 0x%08x registered twice", type); + reporter->InternalError("SerialType 0x%08x registered twice", type); (*factories)[type] = f; (*names)[type] = name; @@ -77,7 +77,7 @@ bool SerialObj::Serialize(SerialInfo* info) const const TransientID* tid = GetTID(); if ( ! tid ) - bro_logger->InternalError("no tid - missing DECLARE_SERIAL?"); + reporter->InternalError("no tid - missing DECLARE_SERIAL?"); if ( info->cache ) pid = info->s->Cache()->Lookup(*tid); @@ -211,7 +211,7 @@ SerialObj* SerialObj::Unserialize(UnserialInfo* info, SerialType type) const TransientID* tid = obj->GetTID(); if ( ! tid ) - bro_logger->InternalError("no tid - missing DECLARE_SERIAL?"); + reporter->InternalError("no tid - missing DECLARE_SERIAL?"); if ( info->cache ) info->s->Cache()->Register(obj, pid, info->new_cache_strategy); diff --git a/src/SerializationFormat.cc b/src/SerializationFormat.cc index 8a8796bf49..b229cbbc87 100644 --- a/src/SerializationFormat.cc +++ b/src/SerializationFormat.cc @@ -5,7 +5,7 @@ #include "net_util.h" #include "SerializationFormat.h" #include "Serializer.h" -#include "Logger.h" +#include "Reporter.h" SerializationFormat::SerializationFormat() { @@ -59,7 +59,7 @@ bool SerializationFormat::ReadData(void* b, size_t count) { if ( input_pos + count > input_len ) { - bro_logger->Error("data underflow during read in binary format"); + reporter->Error("data underflow during read in binary format"); abort(); return false; } @@ -205,7 +205,7 @@ bool BinarySerializationFormat::Read(char** str, int* len, const char* tag) for ( int i = 0; i < l; i++ ) if ( ! s[i] ) { - bro_logger->Error("binary Format: string contains null; replaced by '_'"); + reporter->Error("binary Format: string contains null; replaced by '_'"); s[i] = '_'; } } @@ -333,61 +333,61 @@ XMLSerializationFormat::~XMLSerializationFormat() bool XMLSerializationFormat::Read(int* v, const char* tag) { - bro_logger->InternalError("no reading of xml"); + reporter->InternalError("no reading of xml"); return false; } bool XMLSerializationFormat::Read(uint16* v, const char* tag) { - bro_logger->InternalError("no reading of xml"); + reporter->InternalError("no reading of xml"); return false; } bool XMLSerializationFormat::Read(uint32* v, const char* tag) { - bro_logger->InternalError("no reading of xml"); + reporter->InternalError("no reading of xml"); return false; } bool XMLSerializationFormat::Read(int64* v, const char* tag) { - bro_logger->InternalError("no reading of xml"); + reporter->InternalError("no reading of xml"); return false; } bool XMLSerializationFormat::Read(uint64* v, const char* tag) { - bro_logger->InternalError("no reading of xml"); + reporter->InternalError("no reading of xml"); return false; } bool XMLSerializationFormat::Read(bool* v, const char* tag) { - bro_logger->InternalError("no reading of xml"); + reporter->InternalError("no reading of xml"); return false; } bool XMLSerializationFormat::Read(double* d, const char* tag) { - bro_logger->InternalError("no reading of xml"); + reporter->InternalError("no reading of xml"); return false; } bool XMLSerializationFormat::Read(char* v, const char* tag) { - bro_logger->InternalError("no reading of xml"); + reporter->InternalError("no reading of xml"); return false; } bool XMLSerializationFormat::Read(char** str, int* len, const char* tag) { - bro_logger->InternalError("no reading of xml"); + reporter->InternalError("no reading of xml"); return false; } bool XMLSerializationFormat::Read(string* s, const char* tag) { - bro_logger->InternalError("no reading of xml"); + reporter->InternalError("no reading of xml"); return false; } diff --git a/src/Serializer.cc b/src/Serializer.cc index fad64eb13f..96821408a5 100644 --- a/src/Serializer.cc +++ b/src/Serializer.cc @@ -12,7 +12,7 @@ #include "Serializer.h" #include "Scope.h" #include "Stmt.h" -#include "Logger.h" +#include "Reporter.h" #include "Func.h" #include "Event.h" #include "EventRegistry.h" @@ -911,7 +911,7 @@ bool FileSerializer::Read(UnserialInfo* info, const char* file, bool header) void FileSerializer::ReportError(const char* str) { - bro_logger->Error(str); + reporter->Error(str); } void FileSerializer::GotID(ID* id, Val* val) @@ -971,7 +971,7 @@ ConversionSerializer::~ConversionSerializer() bool ConversionSerializer::Convert(const char* file_in, const char* file_out) { - bro_logger->InternalError("Error: Printing as XML is broken."); + reporter->InternalError("Error: Printing as XML is broken."); if ( ! serout->Open(file_out, true) ) return false; @@ -1004,19 +1004,19 @@ void ConversionSerializer::GotFunctionCall(const char* name, double time, void ConversionSerializer::GotID(ID* id, Val* val) { - bro_logger->Warning("ConversionSerializer::GotID not implemented"); + reporter->Warning("ConversionSerializer::GotID not implemented"); Unref(id); } void ConversionSerializer::GotStateAccess(StateAccess* s) { - bro_logger->Warning("ConversionSerializer::GotID not implemented"); + reporter->Warning("ConversionSerializer::GotID not implemented"); delete s; } void ConversionSerializer::GotPacket(Packet* p) { - bro_logger->Warning("ConversionSerializer::GotPacket not implemented"); + reporter->Warning("ConversionSerializer::GotPacket not implemented"); delete p; } diff --git a/src/Serializer.h b/src/Serializer.h index 214dc83873..6bdac10f83 100644 --- a/src/Serializer.h +++ b/src/Serializer.h @@ -18,7 +18,7 @@ #include "IP.h" #include "Timer.h" #include "IOSource.h" -#include "Logger.h" +#include "Reporter.h" class SerializationCache; class SerialInfo; @@ -263,7 +263,7 @@ public: virtual ~CloneSerializer() { } protected: - virtual void ReportError(const char* msg) { bro_logger->Error(msg); } + virtual void ReportError(const char* msg) { reporter->Error(msg); } virtual void GotID(ID* id, Val* val) { } virtual void GotEvent(const char* name, double time, EventHandlerPtr event, val_list* args) { } diff --git a/src/Sessions.cc b/src/Sessions.cc index 151ba5c971..a98b3882f8 100644 --- a/src/Sessions.cc +++ b/src/Sessions.cc @@ -15,7 +15,7 @@ #include "Timer.h" #include "NetVar.h" #include "Sessions.h" -#include "Logger.h" +#include "Reporter.h" #include "OSFinger.h" #include "ICMP.h" @@ -572,7 +572,7 @@ void NetSessions::DoNextPacket(double t, const struct pcap_pkthdr* hdr, HashKey* h = id.BuildConnKey(); if ( ! h ) - bro_logger->InternalError("hash computation failed"); + reporter->InternalError("hash computation failed"); Connection* conn = 0; @@ -761,7 +761,7 @@ FragReassembler* NetSessions::NextFragment(double t, const IP_Hdr* ip, HashKey* h = ch->ComputeHash(key, 1); if ( ! h ) - bro_logger->InternalError("hash computation failed"); + reporter->InternalError("hash computation failed"); FragReassembler* f = fragments.Lookup(h); if ( ! f ) @@ -855,7 +855,7 @@ Connection* NetSessions::FindConnection(Val* v) HashKey* h = id.BuildConnKey(); if ( ! h ) - bro_logger->InternalError("hash computation failed"); + reporter->InternalError("hash computation failed"); Dictionary* d; @@ -933,21 +933,21 @@ void NetSessions::Remove(Connection* c) ; else if ( ! tcp_conns.RemoveEntry(k) ) - bro_logger->InternalError("connection missing"); + reporter->InternalError("connection missing"); break; case TRANSPORT_UDP: if ( ! udp_conns.RemoveEntry(k) ) - bro_logger->InternalError("connection missing"); + reporter->InternalError("connection missing"); break; case TRANSPORT_ICMP: if ( ! icmp_conns.RemoveEntry(k) ) - bro_logger->InternalError("connection missing"); + reporter->InternalError("connection missing"); break; case TRANSPORT_UNKNOWN: - bro_logger->InternalError("unknown transport when removing connection"); + reporter->InternalError("unknown transport when removing connection"); break; } @@ -960,10 +960,10 @@ void NetSessions::Remove(FragReassembler* f) { HashKey* k = f->Key(); if ( ! k ) - bro_logger->InternalError("fragment block not in dictionary"); + reporter->InternalError("fragment block not in dictionary"); if ( ! fragments.RemoveEntry(k) ) - bro_logger->InternalError("fragment block missing"); + reporter->InternalError("fragment block missing"); Unref(f); } @@ -999,7 +999,7 @@ void NetSessions::Insert(Connection* c) break; default: - bro_logger->InternalError("unknown connection type"); + reporter->InternalError("unknown connection type"); } if ( old && old != c ) @@ -1123,7 +1123,7 @@ Connection* NetSessions::NewConn(HashKey* k, double t, const ConnID* id, tproto = TRANSPORT_UDP; break; default: - bro_logger->InternalError("unknown transport protocol"); + reporter->InternalError("unknown transport protocol"); break; }; @@ -1310,7 +1310,7 @@ void NetSessions::DumpPacket(const struct pcap_pkthdr* hdr, struct pcap_pkthdr h = *hdr; h.caplen = len; if ( h.caplen > hdr->caplen ) - bro_logger->InternalError("bad modified caplen"); + reporter->InternalError("bad modified caplen"); pkt_dumper->Dump(&h, pkt); } } @@ -1319,7 +1319,7 @@ void NetSessions::Internal(const char* msg, const struct pcap_pkthdr* hdr, const u_char* pkt) { DumpPacket(hdr, pkt); - bro_logger->InternalError("%s", msg); + reporter->InternalError("%s", msg); } void NetSessions::Weird(const char* name, @@ -1328,12 +1328,12 @@ void NetSessions::Weird(const char* name, if ( hdr ) dump_this_packet = 1; - bro_logger->Weird(name); + reporter->Weird(name); } void NetSessions::Weird(const char* name, const IP_Hdr* ip) { - bro_logger->Weird(ip->SrcAddr4(), ip->DstAddr4(), name); + reporter->Weird(ip->SrcAddr4(), ip->DstAddr4(), name); } unsigned int NetSessions::ConnectionMemoryUsage() diff --git a/src/SmithWaterman.cc b/src/SmithWaterman.cc index 38860f9896..3f27018550 100644 --- a/src/SmithWaterman.cc +++ b/src/SmithWaterman.cc @@ -10,7 +10,7 @@ #include "SmithWaterman.h" #include "Var.h" #include "util.h" -#include "Logger.h" +#include "Reporter.h" BroSubstring::BroSubstring(const BroSubstring& bst) : BroString((const BroString&) bst), _new(bst._new) @@ -186,7 +186,7 @@ bool BroSubstringCmp::operator()(const BroSubstring* bst1, if ( _index >= bst1->GetNumAlignments() || _index >= bst2->GetNumAlignments() ) { - bro_logger->Warning("BroSubstringCmp::operator(): invalid index for input strings.\n"); + reporter->Warning("BroSubstringCmp::operator(): invalid index for input strings.\n"); return false; } diff --git a/src/StateAccess.cc b/src/StateAccess.cc index 449885ecb0..ef4c257f6b 100644 --- a/src/StateAccess.cc +++ b/src/StateAccess.cc @@ -235,7 +235,7 @@ bool StateAccess::MergeTables(TableVal* dst, Val* src) { if ( ! src->Type()->Tag() == TYPE_TABLE ) { - bro_logger->Error("type mismatch while merging tables"); + reporter->Error("type mismatch while merging tables"); return false; } @@ -269,8 +269,8 @@ void StateAccess::Replay() { // FIXME: I think this warrants an internal error, // but let's check that first ... - // bro_logger->InternalError("replay id lacking a value"); - bro_logger->Error("replay id lacks a value"); + // reporter->InternalError("replay id lacking a value"); + reporter->Error("replay id lacks a value"); return; } @@ -352,7 +352,7 @@ void StateAccess::Replay() v->AsRecordVal()->Assign(idx, op2 ? op2->Ref() : 0); } else - bro_logger->Error(fmt("access replay: unknown record field %s for assign", field)); + reporter->Error(fmt("access replay: unknown record field %s for assign", field)); } else if ( t == TYPE_VECTOR ) @@ -377,7 +377,7 @@ void StateAccess::Replay() } else - bro_logger->InternalError("unknown type in replaying index assign"); + reporter->InternalError("unknown type in replaying index assign"); break; @@ -413,7 +413,7 @@ void StateAccess::Replay() v->AsRecordVal()->Assign(idx, new_val, OP_INCR); } else - bro_logger->Error(fmt("access replay: unknown record field %s for assign", field)); + reporter->Error(fmt("access replay: unknown record field %s for assign", field)); } else if ( t == TYPE_VECTOR ) @@ -427,7 +427,7 @@ void StateAccess::Replay() } else - bro_logger->InternalError("unknown type in replaying index increment"); + reporter->InternalError("unknown type in replaying index increment"); break; } @@ -489,7 +489,7 @@ void StateAccess::Replay() case OP_PRINT: assert(op1.val); - bro_logger->InternalError("access replay for print not implemented"); + reporter->InternalError("access replay for print not implemented"); break; case OP_READ_IDX: @@ -518,11 +518,11 @@ void StateAccess::Replay() } } else - bro_logger->Error("read for non-table"); + reporter->Error("read for non-table"); break; default: - bro_logger->InternalError("access replay: unknown opcode for StateAccess"); + reporter->InternalError("access replay: unknown opcode for StateAccess"); break; } @@ -630,7 +630,7 @@ bool StateAccess::DoSerialize(SerialInfo* info) const break; default: - bro_logger->InternalError("StateAccess::DoSerialize: unknown opcode"); + reporter->InternalError("StateAccess::DoSerialize: unknown opcode"); } } @@ -854,7 +854,7 @@ void StateAccess::Describe(ODesc* d) const break; default: - bro_logger->InternalError("unknown opcode for StateAccess"); + reporter->InternalError("unknown opcode for StateAccess"); break; } diff --git a/src/Stats.cc b/src/Stats.cc index 28c0b38c22..126417dbd2 100644 --- a/src/Stats.cc +++ b/src/Stats.cc @@ -21,7 +21,7 @@ uint32 tot_gap_bytes = 0; class ProfileTimer : public Timer { public: - ProfileTimer(double t, ProfileLogger* l, double i) + ProfileTimer(double t, ProfileReporter* l, double i) : Timer(t, TIMER_PROFILE) { logger = l; @@ -32,7 +32,7 @@ public: protected: double interval; - ProfileLogger* logger; + ProfileReporter* logger; }; void ProfileTimer::Dispatch(double t, int is_expire) @@ -46,7 +46,7 @@ void ProfileTimer::Dispatch(double t, int is_expire) } -ProfileLogger::ProfileLogger(BroFile* arg_file, double interval) +ProfileReporter::ProfileReporter(BroFile* arg_file, double interval) : SegmentStatsReporter() { file = arg_file; @@ -54,12 +54,12 @@ ProfileLogger::ProfileLogger(BroFile* arg_file, double interval) timer_mgr->Add(new ProfileTimer(1, this, interval)); } -ProfileLogger::~ProfileLogger() +ProfileReporter::~ProfileReporter() { file->Close(); } -void ProfileLogger::Log() +void ProfileReporter::Log() { if ( terminating ) // Connections have been flushed already. @@ -285,7 +285,7 @@ void ProfileLogger::Log() } } -void ProfileLogger::SegmentProfile(const char* name, const Location* loc, +void ProfileReporter::SegmentProfile(const char* name, const Location* loc, double dtime, int dmem) { if ( name ) @@ -303,7 +303,7 @@ void ProfileLogger::SegmentProfile(const char* name, const Location* loc, } -SampleLogger::SampleLogger() +SampleReporter::SampleReporter() { static TableType* load_sample_info = 0; @@ -313,22 +313,22 @@ SampleLogger::SampleLogger() load_samples = new TableVal(load_sample_info); } -SampleLogger::~SampleLogger() +SampleReporter::~SampleReporter() { Unref(load_samples); } -void SampleLogger::FunctionSeen(const Func* func) +void SampleReporter::FunctionSeen(const Func* func) { load_samples->Assign(new StringVal(func->GetID()->Name()), 0); } -void SampleLogger::LocationSeen(const Location* loc) +void SampleReporter::LocationSeen(const Location* loc) { load_samples->Assign(new StringVal(loc->filename), 0); } -void SampleLogger::SegmentProfile(const char* /* name */, +void SampleReporter::SegmentProfile(const char* /* name */, const Location* /* loc */, double dtime, int dmem) { diff --git a/src/Stats.h b/src/Stats.h index 8acb7ef190..8d40f77356 100644 --- a/src/Stats.h +++ b/src/Stats.h @@ -73,10 +73,10 @@ protected: }; -class ProfileLogger : public SegmentStatsReporter { +class ProfileReporter : public SegmentStatsReporter { public: - ProfileLogger(BroFile* file, double interval); - ~ProfileLogger(); + ProfileReporter(BroFile* file, double interval); + ~ProfileReporter(); void Log(); BroFile* File() { return file; } @@ -92,10 +92,10 @@ private: // Generates load_sample() events. -class SampleLogger : public SegmentStatsReporter { +class SampleReporter : public SegmentStatsReporter { public: - SampleLogger(); - ~SampleLogger(); + SampleReporter(); + ~SampleReporter(); // These are called to report that a given function or location // has been seen during the sampling. @@ -110,9 +110,9 @@ protected: }; -extern ProfileLogger* profiling_logger; -extern ProfileLogger* segment_logger; -extern SampleLogger* sample_logger; +extern ProfileReporter* profiling_logger; +extern ProfileReporter* segment_logger; +extern SampleReporter* sample_logger; // Connection statistics. extern int killed_by_inactivity; diff --git a/src/Stmt.cc b/src/Stmt.cc index 9d5c2fea0c..ee7c0784a4 100644 --- a/src/Stmt.cc +++ b/src/Stmt.cc @@ -8,7 +8,7 @@ #include "Event.h" #include "Frame.h" #include "File.h" -#include "Logger.h" +#include "Reporter.h" #include "NetVar.h" #include "Stmt.h" #include "Scope.h" @@ -2060,7 +2060,7 @@ int same_stmt(const Stmt* s1, const Stmt* s2) return 1; default: - bro_logger->Error("bad tag in same_stmt()"); + reporter->Error("bad tag in same_stmt()"); } return 0; diff --git a/src/Stmt.h b/src/Stmt.h index 6e9ec5e2e6..bbfdd98bfd 100644 --- a/src/Stmt.h +++ b/src/Stmt.h @@ -10,7 +10,7 @@ #include "BroList.h" #include "Obj.h" #include "Expr.h" -#include "Logger.h" +#include "Reporter.h" #include "StmtEnums.h" @@ -63,7 +63,7 @@ public: if ( breakpoint_count ) --breakpoint_count; else - bro_logger->InternalError("breakpoint count decremented below 0"); + reporter->InternalError("breakpoint count decremented below 0"); } virtual unsigned int BPCount() const { return breakpoint_count; } diff --git a/src/TCP.cc b/src/TCP.cc index 1f6045fdf7..4c56eb7ff9 100644 --- a/src/TCP.cc +++ b/src/TCP.cc @@ -1589,7 +1589,7 @@ BroFile* TCP_Analyzer::GetContentsFile(unsigned int direction) const default: break; } - bro_logger->InternalError("inconsistency in TCP_Analyzer::GetContentsFile"); + reporter->InternalError("inconsistency in TCP_Analyzer::GetContentsFile"); return 0; } diff --git a/src/TCP_Endpoint.cc b/src/TCP_Endpoint.cc index 4e705d1024..6d74a1d818 100644 --- a/src/TCP_Endpoint.cc +++ b/src/TCP_Endpoint.cc @@ -208,7 +208,7 @@ int TCP_Endpoint::DataSent(double t, int seq, int len, int caplen, if ( fwrite(data, 1, len, f) < unsigned(len) ) // ### this should really generate an event - bro_logger->InternalError("contents write failed"); + reporter->InternalError("contents write failed"); } return status; diff --git a/src/TCP_Reassembler.cc b/src/TCP_Reassembler.cc index ee5b28f107..bbde905320 100644 --- a/src/TCP_Reassembler.cc +++ b/src/TCP_Reassembler.cc @@ -104,7 +104,7 @@ void TCP_Reassembler::SetContentsFile(BroFile* f) { if ( ! f->IsOpen() ) { - bro_logger->Error("no such file \"%s\"", f->Name()); + reporter->Error("no such file \"%s\"", f->Name()); return; } @@ -173,7 +173,7 @@ void TCP_Reassembler::Undelivered(int up_to_seq) if ( seq_delta(up_to_seq, last_reassem_seq) <= 0 ) // This should never happen. - bro_logger->InternalError("Calling Undelivered for data that has already been delivered (or has already been marked as undelivered"); + reporter->InternalError("Calling Undelivered for data that has already been delivered (or has already been marked as undelivered"); if ( last_reassem_seq == 1 && (endpoint->FIN_cnt > 0 || endpoint->RST_cnt > 0 || @@ -323,14 +323,14 @@ void TCP_Reassembler::RecordBlock(DataBlock* b, BroFile* f) unsigned int len = b->Size(); if ( ! f->Write((const char*) b->block, len) ) // ### this should really generate an event - bro_logger->InternalError("contents write failed"); + reporter->InternalError("contents write failed"); } void TCP_Reassembler::RecordGap(int start_seq, int upper_seq, BroFile* f) { if ( ! f->Write(fmt("\n<>\n", seq_delta(upper_seq, start_seq))) ) // ### this should really generate an event - bro_logger->InternalError("contents gap write failed"); + reporter->InternalError("contents gap write failed"); } void TCP_Reassembler::BlockInserted(DataBlock* start_block) @@ -407,13 +407,13 @@ IMPLEMENT_SERIAL(TCP_Reassembler, SER_TCP_REASSEMBLER); bool TCP_Reassembler::DoSerialize(SerialInfo* info) const { - bro_logger->InternalError("TCP_Reassembler::DoSerialize not implemented"); + reporter->InternalError("TCP_Reassembler::DoSerialize not implemented"); return false; // Cannot be reached. } bool TCP_Reassembler::DoUnserialize(UnserialInfo* info) { - bro_logger->InternalError("TCP_Reassembler::DoUnserialize not implemented"); + reporter->InternalError("TCP_Reassembler::DoUnserialize not implemented"); return false; // Cannot be reached. } diff --git a/src/Timer.cc b/src/Timer.cc index acb491d9db..c7feb0bbd8 100644 --- a/src/Timer.cc +++ b/src/Timer.cc @@ -127,7 +127,7 @@ void PQ_TimerMgr::Add(Timer* timer) // multiple already-added timers are added, they'll still // execute in sorted order. if ( ! q->Add(timer) ) - bro_logger->InternalError("out of memory"); + reporter->InternalError("out of memory"); ++current_timers[timer->Type()]; } @@ -173,7 +173,7 @@ int PQ_TimerMgr::DoAdvance(double new_t, int max_expire) void PQ_TimerMgr::Remove(Timer* timer) { if ( ! q->Remove(timer) ) - bro_logger->InternalError("asked to remove a missing timer"); + reporter->InternalError("asked to remove a missing timer"); --current_timers[timer->Type()]; delete timer; @@ -183,7 +183,7 @@ CQ_TimerMgr::CQ_TimerMgr(const Tag& tag) : TimerMgr(tag) { cq = cq_init(60.0, 1.0); if ( ! cq ) - bro_logger->InternalError("could not initialize calendar queue"); + reporter->InternalError("could not initialize calendar queue"); } CQ_TimerMgr::~CQ_TimerMgr() @@ -208,7 +208,7 @@ void CQ_TimerMgr::Add(Timer* timer) t = network_time; if ( cq_enqueue(cq, t, timer) < 0 ) - bro_logger->InternalError("problem queueing timer"); + reporter->InternalError("problem queueing timer"); ++current_timers[timer->Type()]; } diff --git a/src/Trigger.cc b/src/Trigger.cc index 3a416ba5c9..45d1959ee7 100644 --- a/src/Trigger.cc +++ b/src/Trigger.cc @@ -119,7 +119,7 @@ Trigger::Trigger(Expr* arg_cond, Stmt* arg_body, Stmt* arg_timeout_stmts, Trigger* parent = frame->GetTrigger(); if ( ! parent ) { - bro_logger->Error("return trigger in context which does not allow delaying result"); + reporter->Error("return trigger in context which does not allow delaying result"); Unref(this); return; } diff --git a/src/Type.cc b/src/Type.cc index 442b4bde40..5da892d87f 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -9,7 +9,7 @@ #include "Expr.h" #include "Scope.h" #include "Serializer.h" -#include "Logger.h" +#include "Reporter.h" #include #include @@ -316,7 +316,7 @@ int TypeList::AllMatch(const BroType* t, int is_init) const void TypeList::Append(BroType* t) { if ( pure_type && ! same_type(t, pure_type) ) - bro_logger->InternalError("pure type-list violation"); + reporter->InternalError("pure type-list violation"); types.append(t); } @@ -933,7 +933,7 @@ void RecordType::Init(TypeList* arg_base) if ( fields->Lookup(tdij->id) ) { - bro_logger->Error("duplicate field", tdij->id); + reporter->Error("duplicate field", tdij->id); continue; } @@ -1024,7 +1024,7 @@ const TypeDecl* RecordType::FieldDecl(int field) const { RecordField* rf = fields->NthEntry(field); if ( ! rf ) - bro_logger->InternalError("missing field in RecordType::FieldDecl"); + reporter->InternalError("missing field in RecordType::FieldDecl"); BroType* bt = (*base->Types())[rf->base]; RecordType* rbt = bt->AsRecordType(); @@ -1341,7 +1341,7 @@ CommentedEnumType::~CommentedEnumType() } } -// Note, we use bro_logger->Error() here (not Error()) to include the current script +// Note, we use reporter->Error() here (not Error()) to include the current script // location in the error message, rather than the one where the type was // originally defined. void EnumType::AddName(const string& module_name, const char* name, bool is_export) @@ -1349,7 +1349,7 @@ void EnumType::AddName(const string& module_name, const char* name, bool is_expo /* implicit, auto-increment */ if ( counter < 0) { - bro_logger->Error("cannot mix explicit enumerator assignment and implicit auto-increment"); + reporter->Error("cannot mix explicit enumerator assignment and implicit auto-increment"); SetError(); return; } @@ -1362,7 +1362,7 @@ void EnumType::AddName(const string& module_name, const char* name, bro_int_t va /* explicit value specified */ if ( counter > 0 ) { - bro_logger->Error("cannot mix explicit enumerator assignment and implicit auto-increment"); + reporter->Error("cannot mix explicit enumerator assignment and implicit auto-increment"); SetError(); return; } @@ -1395,7 +1395,7 @@ void EnumType::AddNameInternal(const string& module_name, const char* name, bro_ ID *id; if ( Lookup(val) ) { - bro_logger->Error("enumerator value in enumerated type definition already exists"); + reporter->Error("enumerator value in enumerated type definition already exists"); SetError(); return; } @@ -1409,7 +1409,7 @@ void EnumType::AddNameInternal(const string& module_name, const char* name, bro_ } else { - bro_logger->Error("identifier or enumerator value in enumerated type definition already exists"); + reporter->Error("identifier or enumerator value in enumerated type definition already exists"); SetError(); return; } @@ -1776,7 +1776,7 @@ int same_type(const BroType* t1, const BroType* t2, int is_init) return same_type(t1, t2, is_init); case TYPE_UNION: - bro_logger->Error("union type in same_type()"); + reporter->Error("union type in same_type()"); } return 0; } @@ -1821,7 +1821,7 @@ const BroType* flatten_type(const BroType* t) const type_list* types = tl->Types(); if ( types->length() == 0 ) - bro_logger->InternalError("empty type list in flatten_type"); + reporter->InternalError("empty type list in flatten_type"); const BroType* ft = (*types)[0]; if ( types->length() == 1 || tl->AllMatch(ft, 0) ) @@ -1870,7 +1870,7 @@ int is_assignable(BroType* t) return 0; case TYPE_UNION: - bro_logger->Error("union type in is_assignable()"); + reporter->Error("union type in is_assignable()"); } return 0; @@ -1899,7 +1899,7 @@ TypeTag max_type(TypeTag t1, TypeTag t2) } else { - bro_logger->InternalError("non-arithmetic tags in max_type()"); + reporter->InternalError("non-arithmetic tags in max_type()"); return TYPE_ERROR; } } @@ -1994,7 +1994,7 @@ BroType* merge_types(const BroType* t1, const BroType* t2) return new TableType(tl3, y3); else { - bro_logger->InternalError("bad tag in merge_types"); + reporter->InternalError("bad tag in merge_types"); return 0; } } @@ -2112,11 +2112,11 @@ BroType* merge_types(const BroType* t1, const BroType* t2) return new FileType(merge_types(t1->YieldType(), t2->YieldType())); case TYPE_UNION: - bro_logger->InternalError("union type in merge_types()"); + reporter->InternalError("union type in merge_types()"); return 0; default: - bro_logger->InternalError("bad type in merge_types()"); + reporter->InternalError("bad type in merge_types()"); return 0; } } @@ -2128,7 +2128,7 @@ BroType* merge_type_list(ListExpr* elements) if ( tl->length() < 1 ) { - bro_logger->Error("no type can be inferred for empty list"); + reporter->Error("no type can be inferred for empty list"); return 0; } @@ -2145,7 +2145,7 @@ BroType* merge_type_list(ListExpr* elements) } if ( ! t ) - bro_logger->Error("inconsistent types in list"); + reporter->Error("inconsistent types in list"); return t; } diff --git a/src/UDP.cc b/src/UDP.cc index e9b2f06461..5331560eff 100644 --- a/src/UDP.cc +++ b/src/UDP.cc @@ -9,7 +9,7 @@ #include "Net.h" #include "NetVar.h" #include "UDP.h" -#include "Logger.h" +#include "Reporter.h" UDP_Analyzer::UDP_Analyzer(Connection* conn) : TransportLayerAnalyzer(AnalyzerTag::UDP, conn) @@ -136,7 +136,7 @@ void UDP_Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig, request_len += ulen; #ifdef DEBUG if ( request_len < 0 ) - bro_logger->Warning("wrapping around for UDP request length"); + reporter->Warning("wrapping around for UDP request length"); #endif } @@ -154,7 +154,7 @@ void UDP_Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig, reply_len += ulen; #ifdef DEBUG if ( reply_len < 0 ) - bro_logger->Warning("wrapping around for UDP reply length"); + reporter->Warning("wrapping around for UDP reply length"); #endif } diff --git a/src/Val.cc b/src/Val.cc index 19a9275ef5..5ad77b5aef 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -26,7 +26,7 @@ #include "RemoteSerializer.h" #include "PrefixTable.h" #include "Conn.h" -#include "Logger.h" +#include "Reporter.h" Val::Val(Func* f) @@ -253,7 +253,7 @@ bool Val::DoSerialize(SerialInfo* info) const return false; } - bro_logger->InternalError("should not be reached"); + reporter->InternalError("should not be reached"); return false; } @@ -410,7 +410,7 @@ bool Val::DoUnserialize(UnserialInfo* info) return false; } - bro_logger->InternalError("should not be reached"); + reporter->InternalError("should not be reached"); return false; } @@ -616,7 +616,7 @@ void Val::ValDescribe(ODesc* d) const default: // Don't call Internal(), that'll loop! - bro_logger->InternalError("Val description unavailable"); + reporter->InternalError("Val description unavailable"); } } @@ -964,7 +964,7 @@ AddrVal::AddrVal(const char* text) : Val(TYPE_ADDR) #ifdef BROv6 Init(dotted_to_addr6(text)); #else - bro_logger->Error("bro wasn't compiled with IPv6 support"); + reporter->Error("bro wasn't compiled with IPv6 support"); Init(uint32(0)); #endif } @@ -1085,13 +1085,13 @@ static uint32 parse_dotted(const char* text, int& dots) } else - bro_logger->InternalError("scanf failed in parse_dotted()"); + reporter->InternalError("scanf failed in parse_dotted()"); for ( int i = 0; i <= dots; ++i ) { if ( addr[i] < 0 || addr[i] > 255 ) { - bro_logger->Error("bad dotted address", text); + reporter->Error("bad dotted address", text); break; } } @@ -1105,7 +1105,7 @@ NetVal::NetVal(const char* text) : AddrVal(TYPE_NET) uint32 a = parse_dotted(text, dots); if ( addr_to_net(a) != a ) - bro_logger->Error("bad net address", text); + reporter->Error("bad net address", text); Init(uint32(htonl(a))); } @@ -1998,7 +1998,7 @@ int TableVal::ExpandAndInit(Val* index, Val* new_val) if ( iv->BaseTag() != TYPE_ANY ) { if ( table_type->Indices()->Types()->length() != 1 ) - bro_logger->InternalError("bad singleton list index"); + reporter->InternalError("bad singleton list index"); for ( int i = 0; i < iv->Length(); ++i ) if ( ! ExpandAndInit(iv->Index(i), new_val ? new_val->Ref() : 0) ) @@ -2193,7 +2193,7 @@ Val* TableVal::Delete(const Val* index) Val* va = v ? (v->Value() ? v->Value() : this->Ref()) : 0; if ( subnets && ! subnets->Remove(index) ) - bro_logger->InternalError( "index not in prefix table" ); + reporter->InternalError( "index not in prefix table" ); if ( LoggingAccess() ) { @@ -2235,7 +2235,7 @@ Val* TableVal::Delete(const HashKey* k) { Val* index = table_hash->RecoverVals(k); if ( ! subnets->Remove(index) ) - bro_logger->InternalError( "index not in prefix table" ); + reporter->InternalError( "index not in prefix table" ); Unref(index); } @@ -2316,7 +2316,7 @@ void TableVal::Describe(ODesc* d) const TableEntryVal* v = tbl->NextEntry(k, c); if ( ! v ) - bro_logger->InternalError("hash table underflow in TableVal::Describe"); + reporter->InternalError("hash table underflow in TableVal::Describe"); ListVal* vl = table_hash->RecoverVals(k); int dim = vl->Length(); @@ -2367,7 +2367,7 @@ void TableVal::Describe(ODesc* d) const } if ( tbl->NextEntry(c) ) - bro_logger->InternalError("hash table overflow in TableVal::Describe"); + reporter->InternalError("hash table overflow in TableVal::Describe"); if ( d->IsPortable() || d->IsReadable() ) { @@ -2489,7 +2489,7 @@ void TableVal::DoExpire(double t) { Val* index = RecoverIndex(k); if ( ! subnets->Remove(index) ) - bro_logger->InternalError( "index not in prefix table" ); + reporter->InternalError( "index not in prefix table" ); Unref(index); } @@ -2610,7 +2610,7 @@ bool TableVal::DoSerialize(SerialInfo* info) const state = (State*) info->cont.RestoreState(); } else - bro_logger->InternalError("unknown continuation state"); + reporter->InternalError("unknown continuation state"); HashKey* k; int count = 0; @@ -2695,7 +2695,7 @@ bool TableVal::DoSerialize(SerialInfo* info) const { info->cont.SaveState(state); info->cont.Suspend(); - bro_logger->Message("TableVals serialization suspended right in the middle."); + reporter->Message("TableVals serialization suspended right in the middle."); return true; } } @@ -3489,7 +3489,7 @@ Val* check_and_promote(Val* v, const BroType* t, int is_init) break; default: - bro_logger->InternalError("bad internal type in check_and_promote()"); + reporter->InternalError("bad internal type in check_and_promote()"); Unref(v); return 0; } @@ -3500,7 +3500,7 @@ Val* check_and_promote(Val* v, const BroType* t, int is_init) int same_val(const Val* /* v1 */, const Val* /* v2 */) { - bro_logger->InternalError("same_val not implemented"); + reporter->InternalError("same_val not implemented"); return 0; } @@ -3551,7 +3551,7 @@ int same_atomic_val(const Val* v1, const Val* v2) return subnet_eq(v1->AsSubNet(), v2->AsSubNet()); default: - bro_logger->InternalError("same_atomic_val called for non-atomic value"); + reporter->InternalError("same_atomic_val called for non-atomic value"); return 0; } diff --git a/src/Var.cc b/src/Var.cc index 27340a2cc7..626f3f7e3c 100644 --- a/src/Var.cc +++ b/src/Var.cc @@ -404,7 +404,7 @@ Val* internal_val(const char* name) { ID* id = lookup_ID(name, GLOBAL_MODULE_NAME); if ( ! id ) - bro_logger->InternalError("internal variable %s missing", name); + reporter->InternalError("internal variable %s missing", name); return id->ID_Val(); } @@ -413,10 +413,10 @@ Val* internal_const_val(const char* name) { ID* id = lookup_ID(name, GLOBAL_MODULE_NAME); if ( ! id ) - bro_logger->InternalError("internal variable %s missing", name); + reporter->InternalError("internal variable %s missing", name); if ( ! id->IsConst() ) - bro_logger->InternalError("internal variable %s is not constant", name); + reporter->InternalError("internal variable %s is not constant", name); return id->ID_Val(); } @@ -477,7 +477,7 @@ ListVal* internal_list_val(const char* name) } else - bro_logger->InternalError("internal variable %s is not a list", name); + reporter->InternalError("internal variable %s is not a list", name); } return 0; @@ -487,7 +487,7 @@ BroType* internal_type(const char* name) { ID* id = lookup_ID(name, GLOBAL_MODULE_NAME); if ( ! id ) - bro_logger->InternalError("internal type %s missing", name); + reporter->InternalError("internal type %s missing", name); return id->Type(); } diff --git a/src/X509.cc b/src/X509.cc index de376f0212..783bccdad1 100644 --- a/src/X509.cc +++ b/src/X509.cc @@ -80,7 +80,7 @@ int X509_Cert::init() lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_hash_dir()); if ( ! lookup ) { - bro_logger->Error("X509_Cert::init(): initing lookup failed\n"); + reporter->Error("X509_Cert::init(): initing lookup failed\n"); flag = 1; } @@ -89,7 +89,7 @@ int X509_Cert::init() X509_FILETYPE_PEM); if ( ! i ) { - bro_logger->Error("X509_Cert::init(): error adding lookup directory\n"); + reporter->Error("X509_Cert::init(): error adding lookup directory\n"); ret = 0; } } @@ -108,7 +108,7 @@ int X509_Cert::init() if ( X509_load_crl_file(lookup, (const char*) rString->Bytes(), X509_FILETYPE_PEM) != 1 ) { - bro_logger->Error("X509_Cert::init(): error reading CRL file\n"); + reporter->Error("X509_Cert::init(): error reading CRL file\n"); ret = 1; } diff --git a/src/bro.bif b/src/bro.bif index 541011007e..b9edbb4a25 100644 --- a/src/bro.bif +++ b/src/bro.bif @@ -10,7 +10,7 @@ #include #include -#include "Logger.h" +#include "Reporter.h" using namespace std; @@ -792,7 +792,7 @@ EnumVal* map_conn_type(TransportProto tp) break; default: - bro_logger->InternalError("bad connection type in map_conn_type()"); + reporter->InternalError("bad connection type in map_conn_type()"); } // Cannot be reached; @@ -839,7 +839,7 @@ function sqrt%(x: double%): double %{ if ( x < 0 ) { - bro_logger->Error("negative sqrt argument"); + reporter->Error("negative sqrt argument"); return new Val(-1.0, TYPE_DOUBLE); } @@ -1215,7 +1215,7 @@ function get_orig_seq%(cid: conn_id%): count TYPE_COUNT); else { - bro_logger->Error("connection does not have TCP analyzer"); + reporter->Error("connection does not have TCP analyzer"); return new Val(0, TYPE_COUNT); } %} @@ -1235,7 +1235,7 @@ function get_resp_seq%(cid: conn_id%): count TYPE_COUNT); else { - bro_logger->Error("connection does not have TCP analyzer"); + reporter->Error("connection does not have TCP analyzer"); return new Val(0, TYPE_COUNT); } %} @@ -1414,14 +1414,14 @@ function skip_http_entity_data%(c: connection, is_orig: bool%): any if ( ha->GetTag() == AnalyzerTag::HTTP ) static_cast(ha)->SkipEntityData(is_orig); else - bro_logger->Error("non-HTTP analyzer associated with connection record"); + reporter->Error("non-HTTP analyzer associated with connection record"); } else - bro_logger->Error("could not find analyzer for skip_http_entity_data"); + reporter->Error("could not find analyzer for skip_http_entity_data"); } else - bro_logger->Error("no analyzer associated with connection record"); + reporter->Error("no analyzer associated with connection record"); return 0; %} @@ -1480,7 +1480,7 @@ function resource_usage%(%): bro_resources struct rusage r; if ( getrusage(RUSAGE_SELF, &r) < 0 ) - bro_logger->InternalError("getrusage() failed in bro_resource_usage()"); + reporter->InternalError("getrusage() failed in bro_resource_usage()"); double elapsed_time = current_time() - bro_start_time; @@ -1839,7 +1839,7 @@ function decode_base64%(s: string%): string return new StringVal(t); else { - bro_logger->Error("error in decoding string %s", @ARG@[0]); + reporter->Error("error in decoding string %s", @ARG@[0]); return new StringVal(""); } %} @@ -1971,7 +1971,7 @@ function precompile_pcap_filter%(id: PcapFilterID, s: string%): bool if ( ! pkt_srcs[i]->PrecompileFilter(id->ForceAsInt(), s->CheckString()) ) { - bro_logger->Error( "precompile_pcap_filter: %s", + reporter->Error( "precompile_pcap_filter: %s", pkt_srcs[i]->ErrorMsg() ); success = false; } @@ -1986,7 +1986,7 @@ function install_pcap_filter%(id: PcapFilterID%): bool ID* user_filter = global_scope()->Lookup("cmd_line_bpf_filter"); if ( ! user_filter ) - bro_logger->InternalError("global cmd_line_bpf_filter not defined"); + reporter->InternalError("global cmd_line_bpf_filter not defined"); if ( user_filter->ID_Val()->AsStringVal()->Len() ) // Don't allow the script-level to change the filter when @@ -2169,7 +2169,7 @@ function send_id%(p: event_peer, id: string%) : bool ID* i = global_scope()->Lookup(id->CheckString()); if ( ! i ) { - bro_logger->Error(fmt("send_id: no global id %s", id->CheckString())); + reporter->Error(fmt("send_id: no global id %s", id->CheckString())); return new Val(0, TYPE_BOOL); } @@ -2233,12 +2233,12 @@ function get_event_peer%(%) : event_peer } if ( ! remote_serializer ) - bro_logger->InternalError("remote_serializer not initialized"); + reporter->InternalError("remote_serializer not initialized"); Val* v = remote_serializer->GetPeerVal(src); if ( ! v ) { - bro_logger->Error(fmt("peer %d does not exist anymore", int(src))); + reporter->Error(fmt("peer %d does not exist anymore", int(src))); RecordVal* p = mgr.GetLocalPeerVal(); Ref(p); return p; @@ -2875,7 +2875,7 @@ function lookup_addr%(host: addr%) : string static bool warned = false; if ( ! warned ) { - bro_logger->Warning("lookup_addr() only supports IPv4 addresses currently"); + reporter->Warning("lookup_addr() only supports IPv4 addresses currently"); warned = true; } @@ -2946,14 +2946,14 @@ function disable_analyzer%(cid: conn_id, aid: count%) : bool Connection* c = sessions->FindConnection(cid); if ( ! c ) { - bro_logger->Error("cannot find connection"); + reporter->Error("cannot find connection"); return new Val(0, TYPE_BOOL); } Analyzer* a = c->FindAnalyzer(aid); if ( ! a ) { - bro_logger->Error("connection does not have analyzer specified to disable"); + reporter->Error("connection does not have analyzer specified to disable"); return new Val(0, TYPE_BOOL); } @@ -3233,13 +3233,13 @@ function identify_data%(data: string, return_mime: bool%): string if ( ! *magic ) { - bro_logger->Error(fmt("can't init libmagic: %s", magic_error(*magic))); + reporter->Error(fmt("can't init libmagic: %s", magic_error(*magic))); return new StringVal(""); } if ( magic_load(*magic, 0) < 0 ) { - bro_logger->Error(fmt("can't load magic file: %s", magic_error(*magic))); + reporter->Error(fmt("can't load magic file: %s", magic_error(*magic))); magic_close(*magic); *magic = 0; return new StringVal(""); diff --git a/src/builtin-func.y b/src/builtin-func.y index 2250d8d0c3..c842385627 100644 --- a/src/builtin-func.y +++ b/src/builtin-func.y @@ -635,7 +635,7 @@ body_start: TOK_LPB c_code_begin fprintf(fp_func_def, "\tif ( %s->length() != %d )\n", arg_list_name, argc); fprintf(fp_func_def, "\t\t{\n"); fprintf(fp_func_def, - "\t\tbro_logger->Error(\"%s() takes exactly %d argument(s)\");\n", + "\t\treporter->Error(\"%s() takes exactly %d argument(s)\");\n", decl.bro_fullname.c_str(), argc); fprintf(fp_func_def, "\t\treturn 0;\n"); fprintf(fp_func_def, "\t\t}\n"); @@ -645,7 +645,7 @@ body_start: TOK_LPB c_code_begin fprintf(fp_func_def, "\tif ( %s->length() < %d )\n", arg_list_name, argc); fprintf(fp_func_def, "\t\t{\n"); fprintf(fp_func_def, - "\t\tbro_logger->Error(\"%s() takes at least %d argument(s)\");\n", + "\t\treporter->Error(\"%s() takes at least %d argument(s)\");\n", decl.bro_fullname.c_str(), argc); fprintf(fp_func_def, "\t\treturn 0;\n"); fprintf(fp_func_def, "\t\t}\n"); diff --git a/src/event.bif b/src/event.bif index 0b8376bc02..8065a87530 100644 --- a/src/event.bif +++ b/src/event.bif @@ -479,7 +479,7 @@ event rotate_size%(f: file%); event netflow_v5_header%(h: nf_v5_header%); event netflow_v5_record%(r: nf_v5_record%); -# Different types of log messages. -event log_message%(t: time, msg: string, location: string%); -event log_warning%(t: time, msg: string, location: string%); -event log_error%(t: time, msg: string, location: string%); +# Different types of reporter messages. +event reporter_message%(t: time, msg: string, location: string%); +event reporter_warning%(t: time, msg: string, location: string%); +event reporter_error%(t: time, msg: string, location: string%); diff --git a/src/logging.bif b/src/logging.bif index 90214992b1..0e48633d5a 100644 --- a/src/logging.bif +++ b/src/logging.bif @@ -62,30 +62,6 @@ function Log::__flush%(id: Log::ID%): bool return new Val(result, TYPE_BOOL); %} -function Log::message%(msg: string%): bool - %{ - bro_logger->PushLocation(frame->GetCall()->GetLocationInfo()); - bro_logger->Message("%s", msg->CheckString()); - bro_logger->PopLocation(); - return new Val(1, TYPE_BOOL); - %} - -function Log::warning%(msg: string%): bool - %{ - bro_logger->PushLocation(frame->GetCall()->GetLocationInfo()); - bro_logger->Warning("%s", msg->CheckString()); - bro_logger->PopLocation(); - return new Val(1, TYPE_BOOL); - %} - -function Log::error%(msg: string%): bool - %{ - bro_logger->PushLocation(frame->GetCall()->GetLocationInfo()); - bro_logger->Error("%s", msg->CheckString()); - bro_logger->PopLocation(); - return new Val(1, TYPE_BOOL); - %} - # Options for the ASCII writer. module LogAscii; diff --git a/src/main.cc b/src/main.cc index 59853575f0..21234ef167 100644 --- a/src/main.cc +++ b/src/main.cc @@ -30,7 +30,7 @@ extern "C" void OPENSSL_add_all_algorithms_conf(void); #include "Scope.h" #include "Event.h" #include "File.h" -#include "Logger.h" +#include "Reporter.h" #include "LogMgr.h" #include "Net.h" #include "NetVar.h" @@ -84,9 +84,9 @@ FileSerializer* state_serializer = 0; RemoteSerializer* remote_serializer = 0; EventPlayer* event_player = 0; EventRegistry* event_registry = 0; -ProfileLogger* profiling_logger = 0; -ProfileLogger* segment_logger = 0; -SampleLogger* sample_logger = 0; +ProfileReporter* profiling_logger = 0; +ProfileReporter* segment_logger = 0; +SampleReporter* sample_logger = 0; int signal_val = 0; DPM* dpm = 0; int optimize = 0; @@ -292,7 +292,7 @@ void terminate_bro() delete remote_serializer; delete dpm; delete log_mgr; - delete bro_logger; + delete reporter; } void termination_signal() @@ -300,7 +300,7 @@ void termination_signal() set_processing_status("TERMINATING", "termination_signal"); Val sval(signal_val, TYPE_COUNT); - bro_logger->Message("received termination signal"); + reporter->Message("received termination signal"); net_get_final_stats(); done_with_network(); net_delete(); @@ -652,7 +652,7 @@ int main(int argc, char** argv) set_processing_status("INITIALIZING", "main"); bro_start_time = current_time(true); - bro_logger = new Logger(); + reporter = new Reporter(); init_random_seed(seed, seed_load_file, seed_save_file); // DEBUG_MSG("HMAC key: %s\n", md5_digest_print(shared_hmac_md5_key)); @@ -753,7 +753,7 @@ int main(int argc, char** argv) return 0; } - if ( bro_logger->Errors() > 0 ) + if ( reporter->Errors() > 0 ) { delete dns_mgr; exit(1); @@ -766,7 +766,7 @@ int main(int argc, char** argv) ID* id = global_scope()->Lookup("cmd_line_bpf_filter"); if ( ! id ) - bro_logger->InternalError("global cmd_line_bpf_filter not defined"); + reporter->InternalError("global cmd_line_bpf_filter not defined"); id->SetVal(new StringVal(user_pcap_filter)); } @@ -848,7 +848,7 @@ int main(int argc, char** argv) dns_mgr->Resolve(); if ( ! dns_mgr->Save() ) - bro_logger->FatalError("can't update DNS cache"); + reporter->FatalError("can't update DNS cache"); mgr.Drain(); delete dns_mgr; @@ -890,7 +890,7 @@ int main(int argc, char** argv) ID* id = global_scope()->Lookup(id_name); if ( ! id ) - bro_logger->FatalError("No such ID: %s\n", id_name); + reporter->FatalError("No such ID: %s\n", id_name); ODesc desc; desc.SetQuotes(true); @@ -911,7 +911,7 @@ int main(int argc, char** argv) if ( profiling_interval > 0 ) { - profiling_logger = new ProfileLogger(profiling_file->AsFile(), + profiling_logger = new ProfileReporter(profiling_file->AsFile(), profiling_interval); if ( segment_profiling ) @@ -932,9 +932,9 @@ int main(int argc, char** argv) if ( dead_handlers->length() > 0 && check_for_unused_event_handlers ) { - bro_logger->Warning("event handlers never invoked:"); + reporter->Warning("event handlers never invoked:"); for ( int i = 0; i < dead_handlers->length(); ++i ) - bro_logger->Warning("\t", (*dead_handlers)[i]); + reporter->Warning("\t", (*dead_handlers)[i]); } delete dead_handlers; @@ -944,9 +944,9 @@ int main(int argc, char** argv) if ( alive_handlers->length() > 0 && dump_used_event_handlers ) { - bro_logger->Message("invoked event handlers:"); + reporter->Message("invoked event handlers:"); for ( int i = 0; i < alive_handlers->length(); ++i ) - bro_logger->Message((*alive_handlers)[i]); + reporter->Message((*alive_handlers)[i]); } delete alive_handlers; @@ -968,7 +968,7 @@ int main(int argc, char** argv) dpm->PostScriptInit(); - bro_logger->ReportViaEvents(true); + reporter->ReportViaEvents(true); mgr.Drain(); diff --git a/src/net_util.cc b/src/net_util.cc index 431d2cabe9..d7dc3f4add 100644 --- a/src/net_util.cc +++ b/src/net_util.cc @@ -13,7 +13,7 @@ #include #endif -#include "Logger.h" +#include "Reporter.h" #include "net_util.h" // - adapted from tcpdump @@ -230,14 +230,14 @@ uint32 dotted_to_addr(const char* addr_text) if ( sscanf(addr_text, "%d.%d.%d.%d", addr+0, addr+1, addr+2, addr+3) != 4 ) { - bro_logger->Error("bad dotted address:", addr_text ); + reporter->Error("bad dotted address:", addr_text ); return 0; } if ( addr[0] < 0 || addr[1] < 0 || addr[2] < 0 || addr[3] < 0 || addr[0] > 255 || addr[1] > 255 || addr[2] > 255 || addr[3] > 255 ) { - bro_logger->Error("bad dotted address:", addr_text); + reporter->Error("bad dotted address:", addr_text); return 0; } @@ -254,7 +254,7 @@ uint32* dotted_to_addr6(const char* addr_text) uint32* addr = new uint32[4]; if ( inet_pton(AF_INET6, addr_text, addr) <= 0 ) { - bro_logger->Error("bad IPv6 address:", addr_text ); + reporter->Error("bad IPv6 address:", addr_text ); addr[0] = addr[1] = addr[2] = addr[3] = 0; } @@ -274,7 +274,7 @@ uint32 to_v4_addr(const uint32* addr) { #ifdef BROv6 if ( ! is_v4_addr(addr) ) - bro_logger->InternalError("conversion of non-IPv4 address to IPv4 address"); + reporter->InternalError("conversion of non-IPv4 address to IPv4 address"); return addr[3]; #else return addr[0]; @@ -285,7 +285,7 @@ uint32 mask_addr(uint32 a, uint32 top_bits_to_keep) { if ( top_bits_to_keep > 32 ) { - bro_logger->Error("bad address mask value", top_bits_to_keep); + reporter->Error("bad address mask value", top_bits_to_keep); return a; } @@ -324,7 +324,7 @@ const uint32* mask_addr(const uint32* a, uint32 top_bits_to_keep) if ( top_bits_to_keep == 0 || top_bits_to_keep > max_bits ) { - bro_logger->Error("bad address mask value", top_bits_to_keep); + reporter->Error("bad address mask value", top_bits_to_keep); return addr; } diff --git a/src/parse.y b/src/parse.y index a15da1f8bc..132af965ad 100644 --- a/src/parse.y +++ b/src/parse.y @@ -78,7 +78,7 @@ #include "DNS.h" #include "RE.h" #include "Scope.h" -#include "Logger.h" +#include "Reporter.h" #include "BroDoc.h" #include "BroDocObj.h" @@ -563,7 +563,7 @@ expr: int intval = t->Lookup(id->ModuleName(), id->Name()); if ( intval < 0 ) - bro_logger->InternalError("enum value not found for %s", id->Name()); + reporter->InternalError("enum value not found for %s", id->Name()); $$ = new ConstExpr(new EnumVal(intval, t)); } else @@ -690,7 +690,7 @@ enum_body_elem: assert(cur_enum_type); if ( $4->Type()->Tag() != TYPE_COUNT ) - bro_logger->Error("enumerator is not a count constant"); + reporter->Error("enumerator is not a count constant"); else cur_enum_type->AddName(current_module, $2, $4->InternalUnsigned(), is_export); @@ -708,7 +708,7 @@ enum_body_elem: error message if users triy to use a negative integer (will also catch other cases, but that's fine.) */ - bro_logger->Error("enumerator is not a count constant"); + reporter->Error("enumerator is not a count constant"); } | opt_doc_list TOK_ID @@ -828,7 +828,7 @@ type: | TOK_UNION '{' type_list '}' { set_location(@1, @4); - bro_logger->Error("union type not implemented"); + reporter->Error("union type not implemented"); $$ = 0; } @@ -844,7 +844,7 @@ type: { set_location(@1); // $$ = new TypeList(); - bro_logger->Error("list type not implemented"); + reporter->Error("list type not implemented"); $$ = 0; } @@ -852,7 +852,7 @@ type: { set_location(@1); // $$ = new TypeList($3); - bro_logger->Error("list type not implemented"); + reporter->Error("list type not implemented"); $$ = 0; } @@ -1596,7 +1596,7 @@ resolve_id: $$ = lookup_ID($1, current_module.c_str()); if ( ! $$ ) - bro_logger->Error("identifier not defined:", $1); + reporter->Error("identifier not defined:", $1); delete [] $1; } @@ -1653,7 +1653,7 @@ int yyerror(const char msg[]) strcat(msgbuf, "\nDocumentation mode is enabled: " "remember to check syntax of ## style comments\n"); - bro_logger->Error(msgbuf); + reporter->Error(msgbuf); return 0; } diff --git a/src/re-parse.y b/src/re-parse.y index c9784404db..26c8ab6716 100644 --- a/src/re-parse.y +++ b/src/re-parse.y @@ -8,7 +8,7 @@ #include "CCL.h" #include "NFA.h" #include "EquivClass.h" -#include "Logger.h" +#include "Reporter.h" int csize = 256; int syntax_error = 0; @@ -221,7 +221,7 @@ int clower(int sym) void synerr(const char str[]) { syntax_error = true; - bro_logger->Error("%s (compiling pattern /%s/)", str, RE_parse_input); + reporter->Error("%s (compiling pattern /%s/)", str, RE_parse_input); } void yyerror(const char msg[]) diff --git a/src/reporter.bif b/src/reporter.bif new file mode 100644 index 0000000000..4bbdede145 --- /dev/null +++ b/src/reporter.bif @@ -0,0 +1,30 @@ + +module Reporter; + +%%{ +#include "NetVar.h" +%%} + +function Reporter::message%(msg: string%): bool + %{ + reporter->PushLocation(frame->GetCall()->GetLocationInfo()); + reporter->Message("%s", msg->CheckString()); + reporter->PopLocation(); + return new Val(1, TYPE_BOOL); + %} + +function Reporter::warning%(msg: string%): bool + %{ + reporter->PushLocation(frame->GetCall()->GetLocationInfo()); + reporter->Warning("%s", msg->CheckString()); + reporter->PopLocation(); + return new Val(1, TYPE_BOOL); + %} + +function Reporter::error%(msg: string%): bool + %{ + reporter->PushLocation(frame->GetCall()->GetLocationInfo()); + reporter->Error("%s", msg->CheckString()); + reporter->PopLocation(); + return new Val(1, TYPE_BOOL); + %} diff --git a/src/rule-parse.y b/src/rule-parse.y index f881a67551..73c04a72ab 100644 --- a/src/rule-parse.y +++ b/src/rule-parse.y @@ -3,7 +3,7 @@ #include #include "RuleMatcher.h" -#include "Logger.h" +#include "Reporter.h" extern void begin_PS(); extern void end_PS(); @@ -170,7 +170,7 @@ rule_attr: | TOK_PATTERN_TYPE '[' rangeopt ']' pattern { if ( $3.offset > 0 ) - bro_logger->Warning("Offsets are currently ignored for patterns"); + reporter->Warning("Offsets are currently ignored for patterns"); current_rule->AddPattern($5, $1, 0, $3.len); } @@ -317,14 +317,14 @@ pattern: void rules_error(const char* msg) { - bro_logger->Error("Error in signature (%s:%d): %s\n", + reporter->Error("Error in signature (%s:%d): %s\n", current_rule_file, rules_line_number+1, msg); rule_matcher->SetParseError(); } void rules_error(const char* msg, const char* addl) { - bro_logger->Error("Error in signature (%s:%d): %s (%s)\n", + reporter->Error("Error in signature (%s:%d): %s (%s)\n", current_rule_file, rules_line_number+1, msg, addl); rule_matcher->SetParseError(); } @@ -332,7 +332,7 @@ void rules_error(const char* msg, const char* addl) void rules_error(Rule* r, const char* msg) { const Location& l = r->GetLocation(); - bro_logger->Error("Error in signature %s (%s:%d): %s\n", + reporter->Error("Error in signature %s (%s:%d): %s\n", r->ID(), l.filename, l.first_line, msg); rule_matcher->SetParseError(); } diff --git a/src/scan.l b/src/scan.l index dc54524672..a5ea9afc88 100644 --- a/src/scan.l +++ b/src/scan.l @@ -23,7 +23,7 @@ #include "BroDoc.h" #include "Analyzer.h" #include "AnalyzerTags.h" -#include "Logger.h" +#include "Reporter.h" extern YYLTYPE yylloc; // holds start line and column of token extern int print_loaded_scripts; @@ -49,7 +49,7 @@ char last_tok[128]; // a read fails. #define YY_INPUT(buf,result,max_size) \ if ( ((result = fread(buf, 1, max_size, yyin)) == 0) && ferror(yyin) ) \ - bro_logger->Error(fmt("read failed with \"%s\"", strerror(errno))); + reporter->Error(fmt("read failed with \"%s\"", strerror(errno))); // Files we have already scanned (or are in the process of scanning). static PList(char) files_scanned; @@ -384,7 +384,7 @@ F RET_CONST(new Val(false, TYPE_BOOL)) uint32 p = atoi(yytext); if ( p > 65535 ) { - bro_logger->Error("bad port number -", yytext); + reporter->Error("bad port number -", yytext); p = 0; } RET_CONST(new PortVal(p, TRANSPORT_TCP)) @@ -393,7 +393,7 @@ F RET_CONST(new Val(false, TYPE_BOOL)) uint32 p = atoi(yytext); if ( p > 65535 ) { - bro_logger->Error("bad port number -", yytext); + reporter->Error("bad port number -", yytext); p = 0; } RET_CONST(new PortVal(p, TRANSPORT_UDP)) @@ -402,7 +402,7 @@ F RET_CONST(new Val(false, TYPE_BOOL)) uint32 p = atoi(yytext); if ( p > 255 ) { - bro_logger->Error("bad port number -", yytext); + reporter->Error("bad port number -", yytext); p = 0; } RET_CONST(new PortVal(p, TRANSPORT_ICMP)) @@ -411,7 +411,7 @@ F RET_CONST(new Val(false, TYPE_BOOL)) uint32 p = atoi(yytext); if ( p > 255 ) { - bro_logger->Error("bad port number -", yytext); + reporter->Error("bad port number -", yytext); p = 0; } RET_CONST(new PortVal(p, TRANSPORT_UNKNOWN)) @@ -457,13 +457,13 @@ F RET_CONST(new Val(false, TYPE_BOOL)) { s[i++] = *text; if ( i >= len ) - bro_logger->InternalError("bad string length computation"); + reporter->InternalError("bad string length computation"); } } // Get rid of trailing quote. if ( s[i-1] != '"' ) - bro_logger->InternalError("string scanning confused"); + reporter->InternalError("string scanning confused"); s[i-1] = '\0'; @@ -477,7 +477,7 @@ F RET_CONST(new Val(false, TYPE_BOOL)) [/\\\n] return yytext[0]; -<*>. bro_logger->Error("unrecognized character -", yytext); +<*>. reporter->Error("unrecognized character -", yytext); <> last_tok[0] = '\0'; return EOF; @@ -570,7 +570,7 @@ static int load_files_with_prefix(const char* orig_file) HashKey* key = new HashKey(full_filename); if ( g_dbgfilemaps.Lookup(key) ) { - // bro_logger->Warning("Not re-reading policy file; check BRO_PREFIXES:", full_filename); + // reporter->Warning("Not re-reading policy file; check BRO_PREFIXES:", full_filename); fclose(f); delete key; continue; @@ -616,7 +616,7 @@ static int load_files_with_prefix(const char* orig_file) { if ( streq(prefixes[i], "") ) { - bro_logger->Error("can't open", full_filename); + reporter->Error("can't open", full_filename); exit(1); } } @@ -672,7 +672,7 @@ void do_atifndef(const char *id) void do_atelse() { if ( current_depth == 0 ) - bro_logger->Error("@else without @if..."); + reporter->Error("@else without @if..."); if ( if_stack.length() && current_depth > if_stack.last() ) return; @@ -692,7 +692,7 @@ void do_atelse() void do_atendif() { if ( current_depth == 0 ) - bro_logger->Error("unbalanced @if... @endif"); + reporter->Error("unbalanced @if... @endif"); if ( current_depth == if_stack.last() ) { @@ -728,7 +728,7 @@ const char* get_current_input_filename() void add_input_file(const char* file) { if ( ! file ) - bro_logger->InternalError("empty filename"); + reporter->InternalError("empty filename"); if ( ! filename ) (void) load_files_with_prefix(file); @@ -755,7 +755,7 @@ void add_to_name_list(char* s, char delim, name_list& nl) int yywrap() { - if ( bro_logger->Errors() > 0 ) + if ( reporter->Errors() > 0 ) return 1; --include_level; diff --git a/src/strings.bif b/src/strings.bif index 8a839f5012..d13de8accb 100644 --- a/src/strings.bif +++ b/src/strings.bif @@ -274,7 +274,7 @@ Val* do_split(StringVal* str_val, RE_Matcher* re, TableVal* other_sep, s += offset + end_of_match;; if ( s > end_of_s ) - bro_logger->InternalError("RegMatch in split goes beyond the string"); + reporter->InternalError("RegMatch in split goes beyond the string"); } if ( other_strings ) diff --git a/src/util.cc b/src/util.cc index 8c9b9976bd..4d35075a8c 100644 --- a/src/util.cc +++ b/src/util.cc @@ -38,7 +38,7 @@ #include "Val.h" #include "NetVar.h" #include "Net.h" -#include "Logger.h" +#include "Reporter.h" char* copy_string(const char* s) { @@ -84,7 +84,7 @@ int expand_escape(const char*& s) int result; if ( sscanf(start, "%3o", &result) != 1 ) { - bro_logger->Warning("bad octal escape: ", start); + reporter->Warning("bad octal escape: ", start); result = 0; } @@ -103,7 +103,7 @@ int expand_escape(const char*& s) int result; if ( sscanf(start, "%2x", &result) != 1 ) { - bro_logger->Warning("bad hexadecimal escape: ", start); + reporter->Warning("bad hexadecimal escape: ", start); result = 0; } @@ -230,7 +230,7 @@ unsigned char encode_hex(int h) if ( h < 0 || h >= 16 ) { - bro_logger->InternalError("illegal value for encode_hex: %d", h); + reporter->InternalError("illegal value for encode_hex: %d", h); return 'X'; } @@ -456,7 +456,7 @@ const char* fmt(const char* format, ...) va_end(al); if ( (unsigned int) n >= buf_len ) - bro_logger->InternalError("confusion reformatting in fmt()"); + reporter->InternalError("confusion reformatting in fmt()"); } return buf; @@ -477,14 +477,14 @@ bool ensure_dir(const char *dirname) { if ( errno != ENOENT ) { - bro_logger->Warning(fmt("can't stat directory %s: %s", + reporter->Warning(fmt("can't stat directory %s: %s", dirname, strerror(errno))); return false; } if ( mkdir(dirname, 0700) < 0 ) { - bro_logger->Warning(fmt("can't create directory %s: %s", + reporter->Warning(fmt("can't create directory %s: %s", dirname, strerror(errno))); return false; } @@ -492,7 +492,7 @@ bool ensure_dir(const char *dirname) else if ( ! S_ISDIR(st.st_mode) ) { - bro_logger->Warning(fmt("%s exists but is not a directory", dirname)); + reporter->Warning(fmt("%s exists but is not a directory", dirname)); return false; } @@ -505,7 +505,7 @@ bool is_dir(const char* path) if ( stat(path, &st) < 0 ) { if ( errno != ENOENT ) - bro_logger->Warning(fmt("can't stat %s: %s", path, strerror(errno))); + reporter->Warning(fmt("can't stat %s: %s", path, strerror(errno))); return false; } @@ -537,7 +537,7 @@ uint8 shared_hmac_md5_key[16]; void hmac_md5(size_t size, const unsigned char* bytes, unsigned char digest[16]) { if ( ! hmac_key_set ) - bro_logger->InternalError("HMAC-MD5 invoked before the HMAC key is set"); + reporter->InternalError("HMAC-MD5 invoked before the HMAC key is set"); hash_md5(size, bytes, digest); @@ -555,14 +555,14 @@ static bool read_random_seeds(const char* read_file, uint32* seed, if ( stat(read_file, &st) < 0 ) { - bro_logger->Warning(fmt("Seed file '%s' does not exist: %s", + reporter->Warning(fmt("Seed file '%s' does not exist: %s", read_file, strerror(errno))); return false; } if ( ! (f = fopen(read_file, "r")) ) { - bro_logger->Warning(fmt("Could not open seed file '%s': %s", + reporter->Warning(fmt("Could not open seed file '%s': %s", read_file, strerror(errno))); return false; } @@ -598,7 +598,7 @@ static bool write_random_seeds(const char* write_file, uint32 seed, if ( ! (f = fopen(write_file, "w+")) ) { - bro_logger->Warning(fmt("Could not create seed file '%s': %s", + reporter->Warning(fmt("Could not create seed file '%s': %s", write_file, strerror(errno))); return false; } @@ -633,7 +633,7 @@ void init_random_seed(uint32 seed, const char* read_file, const char* write_file if ( read_file ) { if ( ! read_random_seeds(read_file, &seed, buf, bufsiz) ) - bro_logger->Error("Could not load seeds from file '%s'.\n", + reporter->Error("Could not load seeds from file '%s'.\n", read_file); else seeds_done = true; @@ -696,7 +696,7 @@ void init_random_seed(uint32 seed, const char* read_file, const char* write_file } if ( write_file && ! write_random_seeds(write_file, seed, buf, bufsiz) ) - bro_logger->Error("Could not write seeds to file '%s'.\n", + reporter->Error("Could not write seeds to file '%s'.\n", write_file); } @@ -876,7 +876,7 @@ FILE* rotate_file(const char* name, RecordVal* rotate_info) FILE* newf = fopen(tmpname, "w"); if ( ! newf ) { - bro_logger->Error(fmt("rotate_file: can't open %s: %s", tmpname, strerror(errno))); + reporter->Error(fmt("rotate_file: can't open %s: %s", tmpname, strerror(errno))); return 0; } @@ -885,7 +885,7 @@ FILE* rotate_file(const char* name, RecordVal* rotate_info) struct stat dummy; if ( link(name, newname) < 0 || stat(newname, &dummy) < 0 ) { - bro_logger->Error(fmt("rotate_file: can't move %s to %s: %s", name, newname, strerror(errno))); + reporter->Error(fmt("rotate_file: can't move %s to %s: %s", name, newname, strerror(errno))); fclose(newf); unlink(newname); unlink(tmpname); @@ -895,7 +895,7 @@ FILE* rotate_file(const char* name, RecordVal* rotate_info) // Close current file, and move the tmp to its place. if ( unlink(name) < 0 || link(tmpname, name) < 0 || unlink(tmpname) < 0 ) { - bro_logger->Error(fmt("rotate_file: can't move %s to %s: %s", tmpname, name, strerror(errno))); + reporter->Error(fmt("rotate_file: can't move %s to %s: %s", tmpname, name, strerror(errno))); exit(1); // hard to fix, but shouldn't happen anyway... } @@ -935,7 +935,7 @@ double calc_next_rotate(double interval, const char* rotate_base_time) { struct tm t; if ( ! strptime(rotate_base_time, "%H:%M", &t) ) - bro_logger->Error("calc_next_rotate(): can't parse rotation base time"); + reporter->Error("calc_next_rotate(): can't parse rotation base time"); else base = t.tm_min * 60 + t.tm_hour * 60 * 60; } @@ -998,7 +998,7 @@ double current_time(bool real) { struct timeval tv; if ( gettimeofday(&tv, 0) < 0 ) - bro_logger->InternalError("gettimeofday failed in current_time()"); + reporter->InternalError("gettimeofday failed in current_time()"); double t = double(tv.tv_sec) + double(tv.tv_usec) / 1e6; @@ -1088,7 +1088,7 @@ uint64 calculate_unique_id() void out_of_memory(const char* where) { - bro_logger->FatalError("out of memory in %s.\n", where); + reporter->FatalError("out of memory in %s.\n", where); } void get_memory_usage(unsigned int* total, unsigned int* malloced) diff --git a/testing/btest/Baseline/core.reporter-parse-error/output b/testing/btest/Baseline/core.reporter-parse-error/output new file mode 100644 index 0000000000..f120ca39a2 --- /dev/null +++ b/testing/btest/Baseline/core.reporter-parse-error/output @@ -0,0 +1 @@ +error in /da/home/robin/bro/topic/testing/btest/.tmp/core.reporter-parse-error/reporter-parse-error.bro, line 7: unknown identifier TESTFAILURE, at or near "TESTFAILURE" diff --git a/testing/btest/Baseline/core.reporter-runtime-error/output b/testing/btest/Baseline/core.reporter-runtime-error/output new file mode 100644 index 0000000000..b06159664f --- /dev/null +++ b/testing/btest/Baseline/core.reporter-runtime-error/output @@ -0,0 +1,2 @@ +error in /da/home/robin/bro/topic/testing/btest/.tmp/core.reporter-runtime-error/reporter-runtime-error.bro, line 12: no such index (a[1]) +[script] reporter_error: no such index (a[2]) [/da/home/robin/bro/topic/testing/btest/.tmp/core.reporter-runtime-error/reporter-runtime-error.bro, line 9] [0.000000] diff --git a/testing/btest/Baseline/core.reporter-type-mismatch/output b/testing/btest/Baseline/core.reporter-type-mismatch/output new file mode 100644 index 0000000000..f7c5d1dc89 --- /dev/null +++ b/testing/btest/Baseline/core.reporter-type-mismatch/output @@ -0,0 +1,3 @@ +error in string and /da/home/robin/bro/topic/testing/btest/.tmp/core.reporter-type-mismatch/reporter-type-mismatch.bro, line 11: arithmetic mixed with non-arithmetic (string and 42) +error in /da/home/robin/bro/topic/testing/btest/.tmp/core.reporter-type-mismatch/reporter-type-mismatch.bro, line 11 and string: type mismatch (42 and string) +error in /da/home/robin/bro/topic/testing/btest/.tmp/core.reporter-type-mismatch/reporter-type-mismatch.bro, line 11: argument type mismatch in event invocation (foo(42)) diff --git a/testing/btest/Baseline/core.reporter/logger-test.log b/testing/btest/Baseline/core.reporter/logger-test.log new file mode 100644 index 0000000000..41172ff890 --- /dev/null +++ b/testing/btest/Baseline/core.reporter/logger-test.log @@ -0,0 +1,6 @@ +reporter_message|init test-message|/da/home/robin/bro/topic/testing/btest/.tmp/core.reporter/reporter.bro, line 8|0.000000 +reporter_warning|init test-warning|/da/home/robin/bro/topic/testing/btest/.tmp/core.reporter/reporter.bro, line 9|0.000000 +reporter_error|init test-error|/da/home/robin/bro/topic/testing/btest/.tmp/core.reporter/reporter.bro, line 10|0.000000 +reporter_message|done test-message|/da/home/robin/bro/topic/testing/btest/.tmp/core.reporter/reporter.bro, line 15|0.000000 +reporter_warning|done test-warning|/da/home/robin/bro/topic/testing/btest/.tmp/core.reporter/reporter.bro, line 16|0.000000 +reporter_error|done test-error|/da/home/robin/bro/topic/testing/btest/.tmp/core.reporter/reporter.bro, line 17|0.000000 diff --git a/testing/btest/Baseline/core.reporter/output b/testing/btest/Baseline/core.reporter/output new file mode 100644 index 0000000000..f6ea2ffa55 --- /dev/null +++ b/testing/btest/Baseline/core.reporter/output @@ -0,0 +1,9 @@ +/da/home/robin/bro/topic/testing/btest/.tmp/core.reporter/reporter.bro, line 52: pre test-message +warning in /da/home/robin/bro/topic/testing/btest/.tmp/core.reporter/reporter.bro, line 53: pre test-warning +error in /da/home/robin/bro/topic/testing/btest/.tmp/core.reporter/reporter.bro, line 54: pre test-error +[script] reporter_message: init test-message [/da/home/robin/bro/topic/testing/btest/.tmp/core.reporter/reporter.bro, line 8] [0.000000] +[script] reporter_warning: init test-warning [/da/home/robin/bro/topic/testing/btest/.tmp/core.reporter/reporter.bro, line 9] [0.000000] +[script] reporter_error: init test-error [/da/home/robin/bro/topic/testing/btest/.tmp/core.reporter/reporter.bro, line 10] [0.000000] +[script] reporter_message: done test-message [/da/home/robin/bro/topic/testing/btest/.tmp/core.reporter/reporter.bro, line 15] [0.000000] +[script] reporter_warning: done test-warning [/da/home/robin/bro/topic/testing/btest/.tmp/core.reporter/reporter.bro, line 16] [0.000000] +[script] reporter_error: done test-error [/da/home/robin/bro/topic/testing/btest/.tmp/core.reporter/reporter.bro, line 17] [0.000000] diff --git a/testing/btest/Baseline/logging.logger-parse-error/output b/testing/btest/Baseline/logging.logger-parse-error/output deleted file mode 100644 index 453093d753..0000000000 --- a/testing/btest/Baseline/logging.logger-parse-error/output +++ /dev/null @@ -1 +0,0 @@ -error in /da/home/robin/bro/topic/testing/btest/.tmp/logging.logger-parse-error/logger-parse-error.bro, line 7: unknown identifier TESTFAILURE, at or near "TESTFAILURE" diff --git a/testing/btest/Baseline/logging.logger-runtime-error/output b/testing/btest/Baseline/logging.logger-runtime-error/output deleted file mode 100644 index 290f3e5873..0000000000 --- a/testing/btest/Baseline/logging.logger-runtime-error/output +++ /dev/null @@ -1,2 +0,0 @@ -1309043946.349646 error in /da/home/robin/bro/topic/testing/btest/.tmp/logging.logger-runtime-error/logger-runtime-error.bro, line 12: no such index (a[1]) -[script] log_error: no such index (a[2]) [/da/home/robin/bro/topic/testing/btest/.tmp/logging.logger-runtime-error/logger-runtime-error.bro, line 9] [1309043946.349646] diff --git a/testing/btest/Baseline/logging.logger-type-mismatch/output b/testing/btest/Baseline/logging.logger-type-mismatch/output deleted file mode 100644 index 17e5ef0aa8..0000000000 --- a/testing/btest/Baseline/logging.logger-type-mismatch/output +++ /dev/null @@ -1,3 +0,0 @@ -error in string and /da/home/robin/bro/topic/testing/btest/.tmp/logging.logger-type-mismatch/logger-type-mismatch.bro, line 11: arithmetic mixed with non-arithmetic (string and 42) -error in /da/home/robin/bro/topic/testing/btest/.tmp/logging.logger-type-mismatch/logger-type-mismatch.bro, line 11 and string: type mismatch (42 and string) -error in /da/home/robin/bro/topic/testing/btest/.tmp/logging.logger-type-mismatch/logger-type-mismatch.bro, line 11: argument type mismatch in event invocation (foo(42)) diff --git a/testing/btest/Baseline/logging.logger/logger-test.log b/testing/btest/Baseline/logging.logger/logger-test.log deleted file mode 100644 index 9c11c2c043..0000000000 --- a/testing/btest/Baseline/logging.logger/logger-test.log +++ /dev/null @@ -1,6 +0,0 @@ -log_message|init test-message|/da/home/robin/bro/topic/testing/btest/.tmp/logging.logger/logger.bro, line 8|1309043879.656442 -log_warning|init test-warning|/da/home/robin/bro/topic/testing/btest/.tmp/logging.logger/logger.bro, line 9|1309043879.656442 -log_error|init test-error|/da/home/robin/bro/topic/testing/btest/.tmp/logging.logger/logger.bro, line 10|1309043879.656442 -log_message|done test-message|/da/home/robin/bro/topic/testing/btest/.tmp/logging.logger/logger.bro, line 15|1309043879.656442 -log_warning|done test-warning|/da/home/robin/bro/topic/testing/btest/.tmp/logging.logger/logger.bro, line 16|1309043879.656442 -log_error|done test-error|/da/home/robin/bro/topic/testing/btest/.tmp/logging.logger/logger.bro, line 17|1309043879.656442 diff --git a/testing/btest/Baseline/logging.logger/output b/testing/btest/Baseline/logging.logger/output deleted file mode 100644 index 41b87eb03c..0000000000 --- a/testing/btest/Baseline/logging.logger/output +++ /dev/null @@ -1,9 +0,0 @@ -1309043879.656442 /da/home/robin/bro/topic/testing/btest/.tmp/logging.logger/logger.bro, line 52: pre test-message -1309043879.656442 warning in /da/home/robin/bro/topic/testing/btest/.tmp/logging.logger/logger.bro, line 53: pre test-warning -1309043879.656442 error in /da/home/robin/bro/topic/testing/btest/.tmp/logging.logger/logger.bro, line 54: pre test-error -[script] log_message: init test-message [/da/home/robin/bro/topic/testing/btest/.tmp/logging.logger/logger.bro, line 8] [1309043879.656442] -[script] log_warning: init test-warning [/da/home/robin/bro/topic/testing/btest/.tmp/logging.logger/logger.bro, line 9] [1309043879.656442] -[script] log_error: init test-error [/da/home/robin/bro/topic/testing/btest/.tmp/logging.logger/logger.bro, line 10] [1309043879.656442] -[script] log_message: done test-message [/da/home/robin/bro/topic/testing/btest/.tmp/logging.logger/logger.bro, line 15] [1309043879.656442] -[script] log_warning: done test-warning [/da/home/robin/bro/topic/testing/btest/.tmp/logging.logger/logger.bro, line 16] [1309043879.656442] -[script] log_error: done test-error [/da/home/robin/bro/topic/testing/btest/.tmp/logging.logger/logger.bro, line 17] [1309043879.656442] diff --git a/testing/btest/logging/logger-parse-error.bro b/testing/btest/core/reporter-parse-error.bro similarity index 50% rename from testing/btest/logging/logger-parse-error.bro rename to testing/btest/core/reporter-parse-error.bro index d11781e659..25f33e2785 100644 --- a/testing/btest/logging/logger-parse-error.bro +++ b/testing/btest/core/reporter-parse-error.bro @@ -1,6 +1,6 @@ # # @TEST-EXEC-FAIL: bro %INPUT >output 2>&1 -# @TEST-EXEC: btest-diff output +# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff output event bro_init() { diff --git a/testing/btest/logging/logger-runtime-error.bro b/testing/btest/core/reporter-runtime-error.bro similarity index 60% rename from testing/btest/logging/logger-runtime-error.bro rename to testing/btest/core/reporter-runtime-error.bro index 099a6fab68..330e2a7e5c 100644 --- a/testing/btest/logging/logger-runtime-error.bro +++ b/testing/btest/core/reporter-runtime-error.bro @@ -1,6 +1,6 @@ # # @TEST-EXEC: bro %INPUT >output 2>&1 -# @TEST-EXEC: btest-diff output +# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff output global a: table[count] of count; diff --git a/testing/btest/logging/logger-type-mismatch.bro b/testing/btest/core/reporter-type-mismatch.bro similarity index 56% rename from testing/btest/logging/logger-type-mismatch.bro rename to testing/btest/core/reporter-type-mismatch.bro index b713ac3f52..0faa9b85e2 100644 --- a/testing/btest/logging/logger-type-mismatch.bro +++ b/testing/btest/core/reporter-type-mismatch.bro @@ -1,6 +1,6 @@ # # @TEST-EXEC-FAIL: bro %INPUT >output 2>&1 -# @TEST-EXEC: btest-diff output +# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff output event foo(a: string) { diff --git a/testing/btest/core/reporter.bro b/testing/btest/core/reporter.bro new file mode 100644 index 0000000000..70bb0b665c --- /dev/null +++ b/testing/btest/core/reporter.bro @@ -0,0 +1,55 @@ +# +# @TEST-EXEC: bro %INPUT >output 2>&1 +# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff output +# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff logger-test.log + +event bro_init() +{ + Reporter::message("init test-message"); + Reporter::warning("init test-warning"); + Reporter::error("init test-error"); +} + +event bro_done() +{ + Reporter::message("done test-message"); + Reporter::warning("done test-warning"); + Reporter::error("done test-error"); +} + +global first = 1; + +event connection_established(c: connection) +{ + if ( ! first ) + return; + + print "established"; + + Reporter::message("processing test-message"); + Reporter::warning("processing test-warning"); + Reporter::error("processing test-error"); + first = 0; +} + +global f = open_log_file("logger-test"); + +event reporter_message(t: time, msg: string, location: string) + { + print f, fmt("reporter_message|%s|%s|%.6f", msg, location, t); + } + +event reporter_warning(t: time, msg: string, location: string) + { + print f, fmt("reporter_warning|%s|%s|%.6f", msg, location, t); + } + +event reporter_error(t: time, msg: string, location: string) + { + print f, fmt("reporter_error|%s|%s|%.6f", msg, location, t); + } + +Reporter::message("pre test-message"); +Reporter::warning("pre test-warning"); +Reporter::error("pre test-error"); + diff --git a/testing/btest/logging/logger.bro b/testing/btest/logging/logger.bro deleted file mode 100644 index b9ae812e40..0000000000 --- a/testing/btest/logging/logger.bro +++ /dev/null @@ -1,55 +0,0 @@ -# -# @TEST-EXEC: bro %INPUT >output 2>&1 -# @TEST-EXEC: btest-diff output -# @TEST-EXEC: btest-diff logger-test.log - -event bro_init() -{ - Log::message("init test-message"); - Log::warning("init test-warning"); - Log::error("init test-error"); -} - -event bro_done() -{ - Log::message("done test-message"); - Log::warning("done test-warning"); - Log::error("done test-error"); -} - -global first = 1; - -event connection_established(c: connection) -{ - if ( ! first ) - return; - - print "established"; - - Log::message("processing test-message"); - Log::warning("processing test-warning"); - Log::error("processing test-error"); - first = 0; -} - -global f = open_log_file("logger-test"); - -event log_message(t: time, msg: string, location: string) - { - print f, fmt("log_message|%s|%s|%.6f", msg, location, t); - } - -event log_warning(t: time, msg: string, location: string) - { - print f, fmt("log_warning|%s|%s|%.6f", msg, location, t); - } - -event log_error(t: time, msg: string, location: string) - { - print f, fmt("log_error|%s|%s|%.6f", msg, location, t); - } - -Log::message("pre test-message"); -Log::warning("pre test-warning"); -Log::error("pre test-error"); -