/* * This is an auditd plugin for sending auditd data * to clickhouse DB. * Copyright (C) 2020 Aleksei Nikiforov * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #ifndef AUDITD_PLUGIN_CLICKHOUSE_LOGGING_HPP #define AUDITD_PLUGIN_CLICKHOUSE_LOGGING_HPP #include #include #include #include #include #include class Logger { public: static Logger& instance(); static void open(const char *filename); static void initialize(); static void write(const char *format, ...); static void dump(); private: Logger(); ~Logger(); void open_impl(const char *filename); void initialize_impl(); void write_impl(const char *format, va_list args); void dump_impl(); std::string getdatestring() const; Logger(const Logger &other) = delete; Logger& operator=(const Logger &other) = delete; std::list > m_lines; std::string m_logfile_name; bool m_initialized; static std::mutex s_mutex; }; #endif /* AUDITD_PLUGIN_CLICKHOUSE_LOGGING_HPP */