mirror of
https://github.com/falcosecurity/falco.git
synced 2025-07-16 07:47:00 +00:00
rename digwatch_syslog -> digwatch_logger
This commit is contained in:
parent
4c64295adc
commit
6d72619968
@ -9,7 +9,7 @@ include_directories("${YAMLCPP_INCLUDE_DIR}")
|
||||
include_directories("${LPEG_SRC}")
|
||||
include_directories(${DRAIOS_DEPENDENCIES_DIR}/yaml-${DRAIOS_YAML_VERSION}/target/include)
|
||||
|
||||
add_executable(digwatch configuration.cpp formats.cpp fields.cpp rules.cpp syslog.cpp digwatch.cpp)
|
||||
add_executable(digwatch configuration.cpp formats.cpp fields.cpp rules.cpp logger.cpp digwatch.cpp)
|
||||
|
||||
target_link_libraries(digwatch sinsp)
|
||||
target_link_libraries(digwatch
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "configuration.h"
|
||||
#include "config_digwatch.h"
|
||||
#include "sinsp.h"
|
||||
#include "syslog.h"
|
||||
#include "logger.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -55,6 +55,6 @@ void digwatch_configuration::init(string conf_filename)
|
||||
throw sinsp_exception("Error reading config file (" + m_config_file + "): No outputs configured. Please configure at least one output file output enabled but no filename in configuration block");
|
||||
}
|
||||
|
||||
digwatch_syslog::log_stderr = m_config->get_scalar<bool>("log_stderr", false);
|
||||
digwatch_syslog::log_syslog = m_config->get_scalar<bool>("log_syslog", true);
|
||||
digwatch_logger::log_stderr = m_config->get_scalar<bool>("log_stderr", false);
|
||||
digwatch_logger::log_syslog = m_config->get_scalar<bool>("log_syslog", true);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ extern "C" {
|
||||
#include "rules.h"
|
||||
#include "formats.h"
|
||||
#include "fields.h"
|
||||
#include "syslog.h"
|
||||
#include "logger.h"
|
||||
#include "utils.h"
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
@ -254,7 +254,7 @@ int digwatch_init(int argc, char **argv)
|
||||
conf_stream = new ifstream(conf_filename);
|
||||
if (!conf_stream->good())
|
||||
{
|
||||
digwatch_syslog::log(LOG_ERR, "Could not find configuration file at " + conf_filename + ". Exiting \n");
|
||||
digwatch_logger::log(LOG_ERR, "Could not find configuration file at " + conf_filename + ". Exiting \n");
|
||||
result = EXIT_FAILURE;
|
||||
goto exit;
|
||||
}
|
||||
@ -285,12 +285,12 @@ int digwatch_init(int argc, char **argv)
|
||||
{
|
||||
config.init(conf_filename);
|
||||
// log after config init because config determines where logs go
|
||||
digwatch_syslog::log(LOG_INFO, "Digwatch initialized with configuration file " + conf_filename + "\n");
|
||||
digwatch_logger::log(LOG_INFO, "Digwatch initialized with configuration file " + conf_filename + "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
config.init();
|
||||
digwatch_syslog::log(LOG_INFO, "Digwatch initialized. No configuration file found, proceeding with defaults\n");
|
||||
digwatch_logger::log(LOG_INFO, "Digwatch initialized. No configuration file found, proceeding with defaults\n");
|
||||
}
|
||||
|
||||
if (rules_filename.size())
|
||||
@ -305,7 +305,7 @@ int digwatch_init(int argc, char **argv)
|
||||
lua_main_filename = lua_dir + DIGWATCH_LUA_MAIN;
|
||||
if (!std::ifstream(lua_main_filename))
|
||||
{
|
||||
digwatch_syslog::log(LOG_ERR, "Could not find Digwatch Lua libraries (tried " +
|
||||
digwatch_logger::log(LOG_ERR, "Could not find Digwatch Lua libraries (tried " +
|
||||
string(DIGWATCH_LUA_DIR DIGWATCH_LUA_MAIN) + ", " +
|
||||
lua_main_filename + "). Exiting \n");
|
||||
result = EXIT_FAILURE;
|
||||
@ -324,11 +324,11 @@ int digwatch_init(int argc, char **argv)
|
||||
digwatch_formats::init(inspector, ls);
|
||||
digwatch_fields::init(inspector, ls);
|
||||
|
||||
digwatch_syslog::init(ls);
|
||||
digwatch_logger::init(ls);
|
||||
|
||||
rules->load_rules(config.m_rules_filename);
|
||||
inspector->set_filter(rules->get_filter());
|
||||
digwatch_syslog::log(LOG_INFO, "Parsed rules from file " + config.m_rules_filename + "\n");
|
||||
digwatch_logger::log(LOG_INFO, "Parsed rules from file " + config.m_rules_filename + "\n");
|
||||
|
||||
inspector->set_hostname_and_port_resolution_mode(false);
|
||||
|
||||
@ -361,7 +361,7 @@ int digwatch_init(int argc, char **argv)
|
||||
{
|
||||
if(system("modprobe " PROBE_NAME " > /dev/null 2> /dev/null"))
|
||||
{
|
||||
digwatch_syslog::log(LOG_ERR, "Unable to load the driver. Exiting\n");
|
||||
digwatch_logger::log(LOG_ERR, "Unable to load the driver. Exiting\n");
|
||||
}
|
||||
inspector->open();
|
||||
}
|
||||
@ -374,13 +374,13 @@ int digwatch_init(int argc, char **argv)
|
||||
}
|
||||
catch(sinsp_exception& e)
|
||||
{
|
||||
digwatch_syslog::log(LOG_ERR, "Runtime error: " + string(e.what()) + ". Exiting\n");
|
||||
digwatch_logger::log(LOG_ERR, "Runtime error: " + string(e.what()) + ". Exiting\n");
|
||||
|
||||
result = EXIT_FAILURE;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
digwatch_syslog::log(LOG_ERR, "Unexpected error, Exiting\n");
|
||||
digwatch_logger::log(LOG_ERR, "Unexpected error, Exiting\n");
|
||||
|
||||
result = EXIT_FAILURE;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "formats.h"
|
||||
#include "syslog.h"
|
||||
#include "logger.h"
|
||||
|
||||
|
||||
sinsp* digwatch_formats::s_inspector = NULL;
|
||||
@ -28,7 +28,7 @@ int digwatch_formats::formatter(lua_State *ls)
|
||||
}
|
||||
catch(sinsp_exception& e)
|
||||
{
|
||||
digwatch_syslog::log(LOG_ERR, "Invalid output format '" + format + "'.\n");
|
||||
digwatch_logger::log(LOG_ERR, "Invalid output format '" + format + "'.\n");
|
||||
|
||||
throw sinsp_exception("set_formatter error");
|
||||
}
|
||||
@ -43,7 +43,7 @@ int digwatch_formats::format_event (lua_State *ls)
|
||||
string line;
|
||||
|
||||
if (!lua_islightuserdata(ls, -1) || !lua_islightuserdata(ls, -2)) {
|
||||
digwatch_syslog::log(LOG_ERR, "Invalid arguments passed to format_event()\n");
|
||||
digwatch_logger::log(LOG_ERR, "Invalid arguments passed to format_event()\n");
|
||||
throw sinsp_exception("format_event error");
|
||||
}
|
||||
sinsp_evt* evt = (sinsp_evt*)lua_topointer(ls, 1);
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <ctime>
|
||||
#include "syslog.h"
|
||||
#include "logger.h"
|
||||
#include "chisel_api.h"
|
||||
#include "filterchecks.h"
|
||||
|
||||
@ -7,17 +7,17 @@
|
||||
|
||||
const static struct luaL_reg ll_digwatch [] =
|
||||
{
|
||||
{"syslog", &digwatch_syslog::syslog},
|
||||
{"syslog", &digwatch_logger::syslog},
|
||||
{NULL,NULL}
|
||||
};
|
||||
|
||||
|
||||
void digwatch_syslog::init(lua_State *ls)
|
||||
void digwatch_logger::init(lua_State *ls)
|
||||
{
|
||||
luaL_openlib(ls, "digwatch", ll_digwatch, 0);
|
||||
}
|
||||
|
||||
int digwatch_syslog::syslog(lua_State *ls) {
|
||||
int digwatch_logger::syslog(lua_State *ls) {
|
||||
int priority = luaL_checknumber(ls, 1);
|
||||
|
||||
if (priority > LOG_DEBUG) {
|
||||
@ -30,15 +30,15 @@ int digwatch_syslog::syslog(lua_State *ls) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool digwatch_syslog::log_stderr;
|
||||
bool digwatch_syslog::log_syslog;
|
||||
bool digwatch_logger::log_stderr;
|
||||
bool digwatch_logger::log_syslog;
|
||||
|
||||
void digwatch_syslog::log(int priority, const string msg) {
|
||||
if (digwatch_syslog::log_syslog) {
|
||||
void digwatch_logger::log(int priority, const string msg) {
|
||||
if (digwatch_logger::log_syslog) {
|
||||
::syslog(priority, "%s", msg.c_str());
|
||||
}
|
||||
|
||||
if (digwatch_syslog::log_stderr) {
|
||||
if (digwatch_logger::log_stderr) {
|
||||
std::time_t result = std::time(nullptr);
|
||||
string tstr = std::asctime(std::localtime(&result));
|
||||
tstr = tstr.substr(0, 24);// remove trailling newline
|
@ -9,7 +9,7 @@ extern "C" {
|
||||
#include "lauxlib.h"
|
||||
}
|
||||
|
||||
class digwatch_syslog
|
||||
class digwatch_logger
|
||||
{
|
||||
public:
|
||||
static void init(lua_State *ls);
|
Loading…
Reference in New Issue
Block a user