mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00

* origin/topic/seth/zeek_init: Some more testing fixes. Update docs and tests for bro_(init|done) -> zeek_(init|done) Implement the zeek_init handler.
38 lines
838 B
Text
38 lines
838 B
Text
##! Log the loaded scripts.
|
|
@load base/utils/paths
|
|
|
|
module LoadedScripts;
|
|
|
|
export {
|
|
redef enum Log::ID += { LOG };
|
|
|
|
type Info: record {
|
|
## Name of the script loaded potentially with spaces included
|
|
## before the file name to indicate load depth. The convention
|
|
## is two spaces per level of depth.
|
|
name: string &log;
|
|
};
|
|
}
|
|
|
|
# This is inefficient; however, since this script only executes once on
|
|
# startup, this shold be ok.
|
|
function get_indent(level: count): string
|
|
{
|
|
local out = "";
|
|
while ( level > 0 )
|
|
{
|
|
--level;
|
|
out = out + " ";
|
|
}
|
|
return out;
|
|
}
|
|
|
|
event zeek_init() &priority=5
|
|
{
|
|
Log::create_stream(LoadedScripts::LOG, [$columns=Info, $path="loaded_scripts"]);
|
|
}
|
|
|
|
event bro_script_loaded(path: string, level: count)
|
|
{
|
|
Log::write(LoadedScripts::LOG, [$name=cat(get_indent(level), compress_path(path))]);
|
|
}
|