Migrated file_logger_t to INIT/METHOD macros.
This commit is contained in:
@@ -53,11 +53,9 @@ struct private_file_logger_t {
|
|||||||
bool ike_name;
|
bool ike_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
METHOD(listener_t, log_, bool,
|
||||||
* Implementation of bus_listener_t.log.
|
private_file_logger_t *this, debug_t group, level_t level, int thread,
|
||||||
*/
|
ike_sa_t* ike_sa, char *format, va_list args)
|
||||||
static bool log_(private_file_logger_t *this, debug_t group, level_t level,
|
|
||||||
int thread, ike_sa_t* ike_sa, char *format, va_list args)
|
|
||||||
{
|
{
|
||||||
if (level <= this->levels[group])
|
if (level <= this->levels[group])
|
||||||
{
|
{
|
||||||
@@ -118,10 +116,8 @@ static bool log_(private_file_logger_t *this, debug_t group, level_t level,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(file_logger_t, set_level, void,
|
||||||
* Implementation of file_logger_t.set_level.
|
private_file_logger_t *this, debug_t group, level_t level)
|
||||||
*/
|
|
||||||
static void set_level(private_file_logger_t *this, debug_t group, level_t level)
|
|
||||||
{
|
{
|
||||||
if (group < DBG_ANY)
|
if (group < DBG_ANY)
|
||||||
{
|
{
|
||||||
@@ -136,10 +132,8 @@ static void set_level(private_file_logger_t *this, debug_t group, level_t level)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(file_logger_t, destroy, void,
|
||||||
* Implementation of file_logger_t.destroy.
|
private_file_logger_t *this)
|
||||||
*/
|
|
||||||
static void destroy(private_file_logger_t *this)
|
|
||||||
{
|
{
|
||||||
if (this->out != stdout && this->out != stderr)
|
if (this->out != stdout && this->out != stderr)
|
||||||
{
|
{
|
||||||
@@ -153,18 +147,21 @@ static void destroy(private_file_logger_t *this)
|
|||||||
*/
|
*/
|
||||||
file_logger_t *file_logger_create(FILE *out, char *time_format, bool ike_name)
|
file_logger_t *file_logger_create(FILE *out, char *time_format, bool ike_name)
|
||||||
{
|
{
|
||||||
private_file_logger_t *this = malloc_thing(private_file_logger_t);
|
private_file_logger_t *this;
|
||||||
|
|
||||||
/* public functions */
|
INIT(this,
|
||||||
memset(&this->public.listener, 0, sizeof(listener_t));
|
.public = {
|
||||||
this->public.listener.log = (bool(*)(listener_t*,debug_t,level_t,int,ike_sa_t*,char*,va_list))log_;
|
.listener = {
|
||||||
this->public.set_level = (void(*)(file_logger_t*,debug_t,level_t))set_level;
|
.log = _log_,
|
||||||
this->public.destroy = (void(*)(file_logger_t*))destroy;
|
},
|
||||||
|
.set_level = _set_level,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.out = out,
|
||||||
|
.time_format = time_format,
|
||||||
|
.ike_name = ike_name,
|
||||||
|
);
|
||||||
|
|
||||||
/* private variables */
|
|
||||||
this->out = out;
|
|
||||||
this->time_format = time_format;
|
|
||||||
this->ike_name = ike_name;
|
|
||||||
set_level(this, DBG_ANY, LEVEL_SILENT);
|
set_level(this, DBG_ANY, LEVEL_SILENT);
|
||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
|
|||||||
Reference in New Issue
Block a user