mirror of
https://github.com/falcosecurity/falco.git
synced 2025-08-11 11:02:08 +00:00
chore(userspace/falco): clean up lua deps from logger
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
This commit is contained in:
parent
ac2a9a35cb
commit
0a2eab3f19
@ -16,25 +16,13 @@ limitations under the License.
|
|||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "chisel_api.h"
|
|
||||||
|
|
||||||
#include "falco_common.h"
|
#include "falco_common.h"
|
||||||
#include "banned.h" // This raises a compilation error when certain functions are used
|
#include "banned.h" // This raises a compilation error when certain functions are used
|
||||||
|
|
||||||
const static struct luaL_reg ll_falco [] =
|
|
||||||
{
|
|
||||||
{"syslog", &falco_logger::syslog},
|
|
||||||
{NULL,NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
int falco_logger::level = LOG_INFO;
|
int falco_logger::level = LOG_INFO;
|
||||||
bool falco_logger::time_format_iso_8601 = false;
|
bool falco_logger::time_format_iso_8601 = false;
|
||||||
|
|
||||||
void falco_logger::init(lua_State *ls)
|
|
||||||
{
|
|
||||||
luaL_openlib(ls, "falco", ll_falco, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void falco_logger::set_time_format_iso_8601(bool val)
|
void falco_logger::set_time_format_iso_8601(bool val)
|
||||||
{
|
{
|
||||||
falco_logger::time_format_iso_8601 = val;
|
falco_logger::time_format_iso_8601 = val;
|
||||||
@ -81,19 +69,6 @@ void falco_logger::set_level(string &level)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int falco_logger::syslog(lua_State *ls) {
|
|
||||||
int priority = luaL_checknumber(ls, 1);
|
|
||||||
|
|
||||||
if (priority > LOG_DEBUG) {
|
|
||||||
return luaL_argerror(ls, 1, "falco.syslog: priority must be a number between 0 and 7");
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *msg = luaL_checkstring(ls, 2);
|
|
||||||
::syslog(priority, "%s", msg);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool falco_logger::log_stderr = true;
|
bool falco_logger::log_stderr = true;
|
||||||
bool falco_logger::log_syslog = true;
|
bool falco_logger::log_syslog = true;
|
||||||
|
|
||||||
|
@ -19,25 +19,15 @@ limitations under the License.
|
|||||||
#include "sinsp.h"
|
#include "sinsp.h"
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#include "lua.h"
|
|
||||||
#include "lualib.h"
|
|
||||||
#include "lauxlib.h"
|
|
||||||
}
|
|
||||||
|
|
||||||
class falco_logger
|
class falco_logger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void init(lua_State *ls);
|
|
||||||
|
|
||||||
static void set_time_format_iso_8601(bool val);
|
static void set_time_format_iso_8601(bool val);
|
||||||
|
|
||||||
// Will throw exception if level is unknown.
|
// Will throw exception if level is unknown.
|
||||||
static void set_level(string &level);
|
static void set_level(string &level);
|
||||||
|
|
||||||
// value = falco.syslog(level, message)
|
|
||||||
static int syslog(lua_State *ls);
|
|
||||||
|
|
||||||
static void log(int priority, const string msg);
|
static void log(int priority, const string msg);
|
||||||
|
|
||||||
static int level;
|
static int level;
|
||||||
|
Loading…
Reference in New Issue
Block a user