mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Reformat the world
This commit is contained in:
parent
194cb24547
commit
b2f171ec69
714 changed files with 35149 additions and 35203 deletions
|
@ -5,56 +5,64 @@
|
|||
|
||||
#ifdef DEBUG
|
||||
|
||||
#include <stdio.h>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include "zeek/zeek-config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <set>
|
||||
|
||||
#define DBG_LOG(stream, args...) \
|
||||
if ( ::zeek::detail::debug_logger.IsEnabled(stream) ) \
|
||||
::zeek::detail::debug_logger.Log(stream, args)
|
||||
#define DBG_LOG_VERBOSE(stream, args...) \
|
||||
if ( ::zeek::detail::debug_logger.IsVerbose() && ::zeek::detail::debug_logger.IsEnabled(stream) ) \
|
||||
::zeek::detail::debug_logger.Log(stream, args)
|
||||
#define DBG_LOG(stream, args...) \
|
||||
if ( ::zeek::detail::debug_logger.IsEnabled(stream) ) \
|
||||
::zeek::detail::debug_logger.Log(stream, args)
|
||||
#define DBG_LOG_VERBOSE(stream, args...) \
|
||||
if ( ::zeek::detail::debug_logger.IsVerbose() && \
|
||||
::zeek::detail::debug_logger.IsEnabled(stream) ) \
|
||||
::zeek::detail::debug_logger.Log(stream, args)
|
||||
#define DBG_PUSH(stream) ::zeek::detail::debug_logger.PushIndent(stream)
|
||||
#define DBG_POP(stream) ::zeek::detail::debug_logger.PopIndent(stream)
|
||||
|
||||
#define PLUGIN_DBG_LOG(plugin, args...) ::zeek::detail::debug_logger.Log(plugin, args)
|
||||
|
||||
namespace zeek {
|
||||
namespace zeek
|
||||
{
|
||||
|
||||
namespace plugin { class Plugin; }
|
||||
namespace plugin
|
||||
{
|
||||
class Plugin;
|
||||
}
|
||||
|
||||
// To add a new debugging stream, add a constant here as well as
|
||||
// an entry to DebugLogger::streams in DebugLogger.cc.
|
||||
|
||||
enum DebugStream {
|
||||
DBG_SERIAL, // Serialization
|
||||
DBG_RULES, // Signature matching
|
||||
DBG_STRING, // String code
|
||||
DBG_NOTIFIERS, // Notifiers
|
||||
DBG_MAINLOOP, // Main IOSource loop
|
||||
DBG_ANALYZER, // Analyzer framework
|
||||
DBG_PACKET_ANALYSIS, // Packet analysis
|
||||
DBG_FILE_ANALYSIS, // File analysis
|
||||
DBG_TM, // Time-machine packet input via Brocolli
|
||||
DBG_LOGGING, // Logging streams
|
||||
DBG_INPUT, // Input streams
|
||||
DBG_THREADING, // Threading system
|
||||
DBG_PLUGINS, // Plugin system
|
||||
DBG_ZEEKYGEN, // Zeekygen
|
||||
DBG_PKTIO, // Packet sources and dumpers.
|
||||
DBG_BROKER, // Broker communication
|
||||
DBG_SCRIPTS, // Script initialization
|
||||
DBG_SUPERVISOR, // Process supervisor
|
||||
enum DebugStream
|
||||
{
|
||||
DBG_SERIAL, // Serialization
|
||||
DBG_RULES, // Signature matching
|
||||
DBG_STRING, // String code
|
||||
DBG_NOTIFIERS, // Notifiers
|
||||
DBG_MAINLOOP, // Main IOSource loop
|
||||
DBG_ANALYZER, // Analyzer framework
|
||||
DBG_PACKET_ANALYSIS, // Packet analysis
|
||||
DBG_FILE_ANALYSIS, // File analysis
|
||||
DBG_TM, // Time-machine packet input via Brocolli
|
||||
DBG_LOGGING, // Logging streams
|
||||
DBG_INPUT, // Input streams
|
||||
DBG_THREADING, // Threading system
|
||||
DBG_PLUGINS, // Plugin system
|
||||
DBG_ZEEKYGEN, // Zeekygen
|
||||
DBG_PKTIO, // Packet sources and dumpers.
|
||||
DBG_BROKER, // Broker communication
|
||||
DBG_SCRIPTS, // Script initialization
|
||||
DBG_SUPERVISOR, // Process supervisor
|
||||
|
||||
NUM_DBGS // Has to be last
|
||||
};
|
||||
NUM_DBGS // Has to be last
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class DebugLogger {
|
||||
class DebugLogger
|
||||
{
|
||||
public:
|
||||
// Output goes to stderr per default.
|
||||
DebugLogger();
|
||||
|
@ -63,26 +71,22 @@ public:
|
|||
void OpenDebugLog(const char* filename = 0);
|
||||
|
||||
void Log(DebugStream stream, const char* fmt, ...) __attribute__((format(printf, 3, 4)));
|
||||
void Log(const plugin::Plugin& plugin, const char* fmt, ...) __attribute__((format(printf, 3, 4)));
|
||||
void Log(const plugin::Plugin& plugin, const char* fmt, ...)
|
||||
__attribute__((format(printf, 3, 4)));
|
||||
|
||||
void PushIndent(DebugStream stream)
|
||||
{ ++streams[int(stream)].indent; }
|
||||
void PopIndent(DebugStream stream)
|
||||
{ --streams[int(stream)].indent; }
|
||||
void PushIndent(DebugStream stream) { ++streams[int(stream)].indent; }
|
||||
void PopIndent(DebugStream stream) { --streams[int(stream)].indent; }
|
||||
|
||||
void EnableStream(DebugStream stream)
|
||||
{ streams[int(stream)].enabled = true; }
|
||||
void DisableStream(DebugStream stream)
|
||||
{ streams[int(stream)].enabled = false; }
|
||||
void EnableStream(DebugStream stream) { streams[int(stream)].enabled = true; }
|
||||
void DisableStream(DebugStream stream) { streams[int(stream)].enabled = false; }
|
||||
|
||||
// Takes comma-seperated list of stream prefixes.
|
||||
void EnableStreams(const char* streams);
|
||||
|
||||
bool IsEnabled(DebugStream stream) const
|
||||
{ return streams[int(stream)].enabled; }
|
||||
bool IsEnabled(DebugStream stream) const { return streams[int(stream)].enabled; }
|
||||
|
||||
void SetVerbose(bool arg_verbose) { verbose = arg_verbose; }
|
||||
bool IsVerbose() const { return verbose; }
|
||||
void SetVerbose(bool arg_verbose) { verbose = arg_verbose; }
|
||||
bool IsVerbose() const { return verbose; }
|
||||
|
||||
void ShowStreamsHelp();
|
||||
|
||||
|
@ -90,21 +94,22 @@ private:
|
|||
FILE* file;
|
||||
bool verbose;
|
||||
|
||||
struct Stream {
|
||||
struct Stream
|
||||
{
|
||||
const char* prefix;
|
||||
int indent;
|
||||
bool enabled;
|
||||
};
|
||||
};
|
||||
|
||||
std::set<std::string> enabled_streams;
|
||||
|
||||
static Stream streams[NUM_DBGS];
|
||||
};
|
||||
};
|
||||
|
||||
extern DebugLogger debug_logger;
|
||||
|
||||
} // namespace detail
|
||||
} // namespace zeek
|
||||
} // namespace detail
|
||||
} // namespace zeek
|
||||
|
||||
#else
|
||||
#define DBG_LOG(args...)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue