mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
Renaming the Logger to Reporter.
Also changing output to not include timestamps when we haven't started processing packets yet.
This commit is contained in:
parent
93894eed9b
commit
66e2c3b623
123 changed files with 722 additions and 713 deletions
42
src/util.cc
42
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue