#define _LGPL_SOURCE
#include <assert.h>
#include <inttypes.h>
+#include <pthread.h>
#include <stdlib.h>
#include <string.h>
-#include <errno.h>
-#include <lttng/lttng-error.h>
#include <common/common.h>
+#include <common/thread.h>
+#include <common/compat/errno.h>
#include <common/compat/getenv.h>
+#include <lttng/lttng-error.h>
#include "error.h"
/* TLS variable that contains the time of one single log entry. */
DEFINE_URCU_TLS(struct log_time, error_log_time);
+DEFINE_URCU_TLS(const char *, logger_thread_name);
LTTNG_HIDDEN
const char *log_add_time(void)
return "";
}
+LTTNG_HIDDEN
+void logger_set_thread_name(const char *name, bool set_pthread_name)
+{
+ int ret;
+
+ assert(name);
+ URCU_TLS(logger_thread_name) = name;
+
+ if (set_pthread_name) {
+ ret = lttng_thread_setname(name);
+ if (ret && ret != -ENOSYS) {
+ /* Don't fail as this is not essential. */
+ DBG("Failed to set pthread name attribute");
+ }
+ }
+}
+
/*
* Human readable error message.
*/
[ ERROR_INDEX(LTTNG_ERR_GROUP_NOT_FOUND) ] = "Group not found",
[ ERROR_INDEX(LTTNG_ERR_UNSUPPORTED_DOMAIN) ] = "Unsupported domain used",
[ ERROR_INDEX(LTTNG_ERR_PROCESS_ATTR_TRACKER_INVALID_TRACKING_POLICY) ] = "Operation does not apply to the process attribute tracker's tracking policy",
+ [ ERROR_INDEX(LTTNG_ERR_EVENT_NOTIFIER_GROUP_NOTIFICATION_FD) ] = "Failed to create an event notifier group notification file descriptor",
/* Last element */
[ ERROR_INDEX(LTTNG_ERR_NR) ] = "Unknown error code"