#include "file_logger.h"
+#include <threading/mutex.h>
typedef struct private_file_logger_t private_file_logger_t;
* Print the name/# of the IKE_SA?
*/
bool ike_name;
+
+ /**
+ * Mutex to ensure multi-line log messages are not torn apart
+ */
+ mutex_t *mutex;
};
METHOD(logger_t, log_, void,
vsnprintf(buffer, sizeof(buffer), format, args);
/* prepend a prefix in front of every line */
+ this->mutex->lock(this->mutex);
while (current)
{
next = strchr(current, '\n');
}
current = next;
}
+ this->mutex->unlock(this->mutex);
}
}
{
fclose(this->out);
}
+ this->mutex->destroy(this->mutex);
free(this);
}
.out = out,
.time_format = time_format,
.ike_name = ike_name,
+ .mutex = mutex_create(MUTEX_TYPE_DEFAULT),
);
set_level(this, DBG_ANY, LEVEL_SILENT);
#include "sys_logger.h"
+#include <threading/mutex.h>
typedef struct private_sys_logger_t private_sys_logger_t;
* Print the name/# of the IKE_SA?
*/
bool ike_name;
+
+ /**
+ * Mutex to ensure multi-line log messages are not torn apart
+ */
+ mutex_t *mutex;
};
METHOD(logger_t, log_, void,
}
/* do a syslog for every line */
+ this->mutex->lock(this->mutex);
while (current)
{
next = strchr(current, '\n');
thread, groupstr, namestr, current);
current = next;
}
+ this->mutex->unlock(this->mutex);
}
}
private_sys_logger_t *this)
{
closelog();
+ this->mutex->destroy(this->mutex);
free(this);
}
},
.facility = facility,
.ike_name = ike_name,
+ .mutex = mutex_create(MUTEX_TYPE_DEFAULT),
);
set_level(this, DBG_ANY, LEVEL_SILENT);
/*
- * Copyright (C) 2010 Tobias Brunner
+ * Copyright (C) 2010-2012 Tobias Brunner
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
#include <library.h>
#include <daemon.h>
+#include <threading/mutex.h>
typedef struct private_android_logger_t private_android_logger_t;
*/
int level;
+ /**
+ * Mutex to ensure multi-line log messages are not torn apart
+ */
+ mutex_t *mutex;
};
char *current = buffer, *next;
snprintf(sgroup, sizeof(sgroup), "%N", debug_names, group);
vsnprintf(buffer, sizeof(buffer), format, args);
+ this->mutex->lock(this->mutex);
while (current)
{ /* log each line separately */
next = strchr(current, '\n');
thread, sgroup, current);
current = next;
}
+ this->mutex->unlock(this->mutex);
}
}
METHOD(android_logger_t, destroy, void,
private_android_logger_t *this)
{
+ this->mutex->destroy(this->mutex);
free(this);
}
},
.destroy = _destroy,
},
+ .mutex = mutex_create(MUTEX_TYPE_DEFAULT),
.level = lib->settings->get_int(lib->settings,
"charon.plugins.android.loglevel", 1),
);