2020-01-10 14:59:03 +03:00
/*
* This is an auditd plugin for sending auditd data
* to clickhouse DB .
* Copyright ( C ) 2020 Aleksei Nikiforov < darktemplar @ basealt . ru >
*
* 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 < https : //www.gnu.org/licenses/>.
*
*/
# ifndef AUDITD_PLUGIN_CLICKHOUSE_LOGGING_HPP
# define AUDITD_PLUGIN_CLICKHOUSE_LOGGING_HPP
# include <string>
# include <list>
# include <mutex>
2020-01-15 16:17:46 +03:00
# include <utility>
2020-01-10 14:59:03 +03:00
# include <stdio.h>
# include <stdarg.h>
class Logger
{
public :
static Logger & instance ( ) ;
static void open ( const char * filename ) ;
static void write ( const char * format , . . . ) ;
static void dump ( ) ;
private :
Logger ( ) ;
~ Logger ( ) ;
void open_impl ( const char * filename ) ;
void write_impl ( const char * format , va_list args ) ;
void dump_impl ( ) ;
2020-01-15 16:17:46 +03:00
std : : string getdatestring ( ) const ;
2020-01-10 14:59:03 +03:00
Logger ( const Logger & other ) = delete ;
Logger & operator = ( const Logger & other ) = delete ;
2020-01-15 16:17:46 +03:00
std : : list < std : : pair < std : : string , std : : string > > m_lines ;
2020-01-14 13:06:22 +03:00
std : : string m_logfile_name ;
2020-01-10 14:59:03 +03:00
static std : : mutex s_mutex ;
} ;
# endif /* AUDITD_PLUGIN_CLICKHOUSE_LOGGING_HPP */