ret = -1;
goto end;
}
- DBG("Enabling scheduled rotation timer on session \"%s\" (%ui µs)", session->name,
- interval_us);
+ DBG("Enabling scheduled rotation timer on session \"%s\" (%ui %s)", session->name,
+ interval_us, USEC_UNIT);
ret = timer_start(&session->rotation_schedule_timer, session,
interval_us, LTTNG_SESSIOND_SIG_SCHEDULED_ROTATION,
/* one-shot */ false);
MSG("Traces will be written in %s", print_str_url);
if (opt_live_timer) {
- MSG("Live timer set to %u usec", opt_live_timer);
+ MSG("Live timer set to %u %s", opt_live_timer, USEC_UNIT);
}
} else if (opt_snapshot) {
if (print_str_url) {
goto end;
}
chan_opts.attr.switch_timer_interval = (uint32_t) v;
- DBG("Channel switch timer interval set to %d", chan_opts.attr.switch_timer_interval);
+ DBG("Channel switch timer interval set to %d %s",
+ chan_opts.attr.switch_timer_interval,
+ USEC_UNIT);
break;
}
case OPT_READ_TIMER:
goto end;
}
chan_opts.attr.read_timer_interval = (uint32_t) v;
- DBG("Channel read timer interval set to %d", chan_opts.attr.read_timer_interval);
+ DBG("Channel read timer interval set to %d %s",
+ chan_opts.attr.read_timer_interval,
+ USEC_UNIT);
break;
}
case OPT_MONITOR_TIMER:
}
opt_monitor_timer.interval = (uint64_t) v;
opt_monitor_timer.set = true;
- DBG("Channel monitor timer interval set to %" PRIu64" (µs)", opt_monitor_timer.interval);
+ DBG("Channel monitor timer interval set to %" PRIu64 " %s",
+ opt_monitor_timer.interval,
+ USEC_UNIT);
break;
}
case OPT_BLOCKING_TIMEOUT:
opt_blocking_timeout.value = (int64_t) v;
opt_blocking_timeout.set = true;
- DBG("Channel blocking timeout set to %" PRId64 " µs%s",
+ DBG("Channel blocking timeout set to %" PRId64 " %s%s",
opt_blocking_timeout.value,
+ USEC_UNIT,
opt_blocking_timeout.value == 0 ?
" (non-blocking)" : "");
break;
ret = CMD_SUCCESS;
switch (schedule_type) {
case LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC:
- MSG("Enabled %s rotations every %" PRIu64 " µs on session %s",
- schedule_type_name, value, session_name);
+ MSG("Enabled %s rotations every %" PRIu64 " %s on session %s",
+ schedule_type_name, value, USEC_UNIT, session_name);
break;
case LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD:
MSG("Enabled %s rotations every %" PRIu64 " bytes written on session %s",
}
if (value) {
- MSG("%" PRId64 " µs", value);
+ MSG("%" PRId64 " %s", value, USEC_UNIT);
} else {
MSG("inactive");
}
if (blocking_timeout == -1) {
MSG("%sBlocking timeout: infinite", indent6);
} else {
- MSG("%sBlocking timeout: %" PRId64 " µs", indent6, blocking_timeout);
+ MSG("%sBlocking timeout: %" PRId64 " %s", indent6,
+ blocking_timeout, USEC_UNIT);
}
}
goto end;
}
- MSG(" timer period: %" PRIu64" µs", value);
+ MSG(" timer period: %" PRIu64" %s", value, USEC_UNIT);
ret = CMD_SUCCESS;
end:
return ret;
#include <limits.h>
#include <errno.h>
#include <pthread.h>
+#include <locale.h>
+#include <string.h>
+
+static bool utf8_output_supported;
+
+LTTNG_HIDDEN
+bool locale_supports_utf8(void)
+{
+ return utf8_output_supported;
+}
LTTNG_HIDDEN
int timespec_to_ms(struct timespec ts, unsigned long *ms)
res.tv_nsec = diff % (uint64_t) NSEC_PER_SEC;
return res;
}
+
+static
+void __attribute__((constructor)) init_locale_utf8_support(void)
+{
+ const char *program_locale = setlocale(LC_ALL, NULL);
+ const char *lang = getenv("LANG");
+
+ if (program_locale && strstr(program_locale, "utf8")) {
+ utf8_output_supported = true;
+ } else if (strstr(lang, "utf8")) {
+ utf8_output_supported = true;
+ }
+}
#define LTTNG_TIME_H
#include <time.h>
+#include <stdbool.h>
#define MSEC_PER_SEC 1000ULL
#define NSEC_PER_SEC 1000000000ULL
#define NSEC_PER_MSEC 1000000ULL
#define NSEC_PER_USEC 1000ULL
+bool locale_supports_utf8(void);
+
+#define NSEC_UNIT "ns"
+#define USEC_UNIT (locale_supports_utf8() ? "µs" : "us")
+#define MSEC_UNIT "ms"
+#define SEC_UNIT "s"
+#define MIN_UNIT "m"
+#define HR_UNIT "h"
+
/*
* timespec_to_ms: Convert timespec to milliseconds.
*