mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08: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
54
src/File.cc
54
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue