* SOFTWARE.
*/
+#define BT_LOG_TAG "CLI-CFG-CLI-ARGS"
+#include "logging.h"
+
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "babeltrace-cfg-cli-args.h"
#include "babeltrace-cfg-cli-args-connect.h"
-#define BT_LOG_TAG "CLI-CFG-ARGS"
-#include "logging.h"
-
/*
* Error printf() macro which prepends "Error: " the first time it's
* called. This gives a nicer feel than having a bunch of error prefixes
const char *envvar;
if (bt_common_is_setuid_setgid()) {
- printf_debug("Skipping non-system plugin paths for setuid/setgid binary\n");
+ BT_LOGI_STR("Skipping non-system plugin paths for setuid/setgid binary.");
goto end;
}
if (!omit_home_plugin_path) {
if (bt_common_is_setuid_setgid()) {
- printf_debug("Skipping non-system plugin paths for setuid/setgid binary\n");
+ BT_LOGI_STR("Skipping non-system plugin paths for setuid/setgid binary.");
} else {
char *home_plugin_dir =
bt_common_get_home_plugin_path();
int ret = 0;
if (bt_common_is_setuid_setgid()) {
- printf_debug("Skipping non-system plugin paths for setuid/setgid binary\n");
+ BT_LOGI_STR("Skipping non-system plugin paths for setuid/setgid binary.");
goto end;
}
* modules.
*/
static const char* log_level_env_var_names[] = {
+ "BABELTRACE_COMMON_LOG_LEVEL",
"BABELTRACE_PLUGIN_CTF_BTR_LOG_LEVEL",
"BABELTRACE_PLUGIN_CTF_FS_SRC_LOG_LEVEL",
"BABELTRACE_PLUGIN_CTF_LTTNG_LIVE_SRC_LOG_LEVEL",
"BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL",
"BABELTRACE_PLUGIN_CTF_NOTIF_ITER_LOG_LEVEL",
+ "BABELTRACE_PLUGIN_LTTNG_UTILS_DEBUG_INFO_FLT_LOG_LEVEL",
+ "BABELTRACE_PLUGIN_UTILS_TRIMMER_FLT_LOG_LEVEL",
"BABELTRACE_PYTHON_PLUGIN_PROVIDER_LOG_LEVEL",
NULL,
};
{
const char **env_var_name;
+ /*
+ * Override the configuration's default log level if
+ * BABELTRACE_VERBOSE or BABELTRACE_DEBUG environment variables
+ * are found for backward compatibility with legacy Babetrace 1.
+ */
+ if (getenv("BABELTRACE_DEBUG") &&
+ strcmp(getenv("BABELTRACE_DEBUG"), "1") == 0) {
+ cfg->log_level = 'V';
+ } else if (getenv("BABELTRACE_VERBOSE") &&
+ strcmp(getenv("BABELTRACE_VERBOSE"), "1") == 0) {
+ cfg->log_level = 'I';
+ }
+
/*
* Set log levels according to --debug or --verbose. For
* backward compatibility, --debug is more verbose than
env_var_name++;
}
-
- babeltrace_debug = cfg->debug;
- babeltrace_verbose = cfg->verbose;
}
static
noinst_LTLIBRARIES = libbabeltrace-common.la
-libbabeltrace_common_la_SOURCES = common.c
+libbabeltrace_common_la_SOURCES = common.c logging.c logging.h
* SOFTWARE.
*/
+#define BT_LOG_TAG "COMMON"
+#include "logging.h"
+
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
char *bt_secure_getenv(const char *name)
{
if (bt_common_is_setuid_setgid()) {
- printf_error("Disregarding %s environment variable for setuid/setgid binary",
- name);
+ BT_LOGD("Disregarding environment variable for setuid/setgid binary: "
+ "name=\"%s\"", name);
return NULL;
}
return getenv(name);
{
char *path = NULL;
const char *home_dir;
+ size_t length;
home_dir = bt_get_home_dir();
if (!home_dir) {
goto end;
}
- if (strlen(home_dir) + strlen(HOME_PLUGIN_SUBPATH) + 1 >= PATH_MAX) {
- printf_error("Home directory path is too long: `%s`\n",
- home_dir);
+ length = strlen(home_dir) + strlen(HOME_PLUGIN_SUBPATH) + 1;
+
+ if (length >= PATH_MAX) {
+ BT_LOGW("Home directory path is too long: length=%zu",
+ length);
goto end;
}
page_size = bt_sysconf(_SC_PAGESIZE);
if (page_size < 0) {
- printf_error("Cannot get system page size.");
+ BT_LOGF("Cannot get system's page size: ret=%d",
+ page_size);
abort();
}
--- /dev/null
+/*
+ * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define BT_LOG_OUTPUT_LEVEL bt_common_log_level
+#include <babeltrace/logging-internal.h>
+
+BT_LOG_INIT_LOG_LEVEL(bt_common_log_level, "BABELTRACE_COMMON_LOG_LEVEL");
--- /dev/null
+#ifndef COMMON_LOGGING_H
+#define COMMON_LOGGING_H
+
+/*
+ * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define BT_LOG_OUTPUT_LEVEL bt_common_log_level
+#include <babeltrace/logging-internal.h>
+
+BT_LOG_LEVEL_EXTERN_SYMBOL(bt_common_log_level);
+
+#endif /* COMMON_LOGGING_H */
#define PERROR_BUFLEN 200
-extern bt_bool babeltrace_verbose, babeltrace_debug;
-
-#define printf_verbose(fmt, args...) \
- do { \
- if (babeltrace_verbose) \
- fprintf(stdout, "[verbose] " fmt, ## args); \
- } while (0)
-
-#define printf_debug(fmt, args...) \
- do { \
- if (babeltrace_debug) \
- fprintf(stdout, "[debug] " fmt, ## args); \
- } while (0)
-
-#define _bt_printf(fp, kindstr, fmt, args...) \
- fprintf(fp, "[%s]%s%s%s: " fmt "\n", \
- kindstr, \
- babeltrace_debug ? " \"" : "", \
- babeltrace_debug ? __func__ : "", \
- babeltrace_debug ? "\"" : "", \
- ## args)
-
-#define _bt_printfl(fp, kindstr, lineno, fmt, args...) \
- fprintf(fp, "[%s]%s%s%s at line %u: " fmt "\n", \
- kindstr, \
- babeltrace_debug ? " \"" : "", \
- babeltrace_debug ? __func__ : "", \
- babeltrace_debug ? "\"" : "", \
- lineno, \
- ## args)
-
-#define _bt_printfe(fp, kindstr, perrorstr, fmt, args...) \
- fprintf(fp, "[%s]%s%s%s: %s: " fmt "\n", \
- kindstr, \
- babeltrace_debug ? " \"" : "", \
- babeltrace_debug ? __func__ : "", \
- babeltrace_debug ? "\"" : "", \
- perrorstr, \
- ## args)
-
-#define _bt_printfle(fp, kindstr, lineno, perrorstr, fmt, args...) \
- fprintf(fp, "[%s]%s%s%s at line %u: %s: " fmt "\n", \
- kindstr, \
- babeltrace_debug ? " \"" : "", \
- babeltrace_debug ? __func__ : "", \
- babeltrace_debug ? "\"" : "", \
- lineno, \
- perrorstr, \
- ## args)
-
-#define _bt_printf_perror(fp, fmt, args...) \
- ({ \
- const char *errstr; \
- errstr = g_strerror(errno); \
- _bt_printfe(fp, "error", errstr, fmt, ## args); \
- })
-
-#define _bt_printfl_perror(fp, lineno, fmt, args...) \
- ({ \
- const char *errstr; \
- errstr = g_strerror(errno); \
- _bt_printfle(fp, "error", lineno, errstr, fmt, ## args);\
- })
-
-/* printf without lineno information */
-#define printf_fatal(fmt, args...) \
- _bt_printf(stderr, "fatal", fmt, ## args)
-#define printf_error(fmt, args...) \
- _bt_printf(stderr, "error", fmt, ## args)
-#define printf_warning(fmt, args...) \
- _bt_printf(stderr, "warning", fmt, ## args)
-#define printf_perror(fmt, args...) \
- _bt_printf_perror(stderr, fmt, ## args)
-
-/* printf with lineno information */
-#define printfl_fatal(lineno, fmt, args...) \
- _bt_printfl(stderr, "fatal", lineno, fmt, ## args)
-#define printfl_error(lineno, fmt, args...) \
- _bt_printfl(stderr, "error", lineno, fmt, ## args)
-#define printfl_warning(lineno, fmt, args...) \
- _bt_printfl(stderr, "warning", lineno, fmt, ## args)
-#define printfl_perror(lineno, fmt, args...) \
- _bt_printfl_perror(stderr, lineno, fmt, ## args)
-
-/* printf with node lineno information */
-#define printfn_fatal(node, fmt, args...) \
- _bt_printfl(stderr, "fatal", (node)->lineno, fmt, ## args)
-#define printfn_error(node, fmt, args...) \
- _bt_printfl(stderr, "error", (node)->lineno, fmt, ## args)
-#define printfn_warning(node, fmt, args...) \
- _bt_printfl(stderr, "warning", (node)->lineno, fmt, ## args)
-#define printfn_perror(node, fmt, args...) \
- _bt_printfl_perror(stderr, (node)->lineno, fmt, ## args)
-
-/* fprintf with Node lineno information */
-#define fprintfn_fatal(fp, node, fmt, args...) \
- _bt_printfl(fp, "fatal", (node)->lineno, fmt, ## args)
-#define fprintfn_error(fp, node, fmt, args...) \
- _bt_printfl(fp, "error", (node)->lineno, fmt, ## args)
-#define fprintfn_warning(fp, node, fmt, args...) \
- _bt_printfl(fp, "warning", (node)->lineno, fmt, ## args)
-#define fprintfn_perror(fp, node, fmt, args...) \
- _bt_printfl_perror(fp, (node)->lineno, fmt, ## args)
-
#ifndef likely
# ifdef __GNUC__
# define likely(x) __builtin_expect(!!(x), 1)
#include <babeltrace/types.h>
#include <stdlib.h>
-bt_bool babeltrace_verbose, babeltrace_debug;
-
-static
-void __attribute__((constructor)) init_babeltrace_lib(void)
-{
- if (getenv("BABELTRACE_VERBOSE"))
- babeltrace_verbose = BT_TRUE;
- if (getenv("BABELTRACE_DEBUG"))
- babeltrace_debug = BT_TRUE;
-}
-
int bt_version_get_major(void)
{
return BT_VERSION_MAJOR;
dwarf.h \
bin-info.h \
utils.h \
- copy.h
+ copy.h \
+ logging.c \
+ logging.h
libbabeltrace_plugin_lttng_utils_la_SOURCES = \
plugin.c debug-info.h debug-info.c bin-info.c dwarf.c crc32.c utils.c \
if !BUILT_IN_PLUGINS
libbabeltrace_plugin_lttng_utils_la_LIBADD = \
$(top_builddir)/lib/libbabeltrace.la \
+ $(top_builddir)/common/libbabeltrace-common.la \
+ $(top_builddir)/logging/libbabeltrace-logging.la \
$(top_builddir)/plugins/libctfcopytrace/libctfcopytrace.la
endif
* SOFTWARE.
*/
+#define BT_LOG_TAG "PLUGIN-CTF-LTTNG-UTILS-DEBUG-INFO-FLT-BIN-INFO"
+#include "logging.h"
+
#include <fcntl.h>
#include <math.h>
#include <libgen.h>
#include <dwarf.h>
#include <glib.h>
#include <errno.h>
-#include <babeltrace/babeltrace-internal.h>
#include "dwarf.h"
#include "bin-info.h"
#include "crc32.h"
int ret = 0;
if (elf_version(EV_CURRENT) == EV_NONE) {
- printf_debug("ELF library initialization failed: %s\n",
- elf_errmsg(-1));
+ BT_LOGD("ELF library initialization failed: %s.",
+ elf_errmsg(-1));
ret = -1;
}
elf_fd = open(bin->elf_path, O_RDONLY);
if (elf_fd < 0) {
elf_fd = -errno;
- printf_verbose("Failed to open %s\n", bin->elf_path);
+ BT_LOGD("Failed to open ELF file: path=\"%s\"", bin->elf_path);
goto error;
}
elf_file = elf_begin(elf_fd, ELF_C_READ, NULL);
if (!elf_file) {
- printf_debug("elf_begin failed: %s\n", elf_errmsg(-1));
+ BT_LOGD("elf_begin() failed: %s.", elf_errmsg(-1));
goto error;
}
if (elf_kind(elf_file) != ELF_K_ELF) {
- printf_verbose("Error: %s is not an ELF object\n",
- bin->elf_path);
+ BT_LOGD("ELF file is not an ELF object: path=\"%s\"",
+ bin->elf_path);
goto error;
}
if (!bin->dwarf_info && !bin->is_elf_only) {
ret = bin_info_set_dwarf_info(bin);
if (ret) {
- printf_verbose("Failed to set bin dwarf info, falling back to ELF lookup.\n");
+ BT_LOGD_STR("Failed to set bin dwarf info, falling back to ELF lookup.");
/* Failed to set DWARF info, fallback to ELF. */
bin->is_elf_only = true;
}
if (bin->is_elf_only) {
ret = bin_info_lookup_elf_function_name(bin, addr, &_func_name);
- printf_verbose("Failed to lookup function name (elf), error %i\n", ret);
+ BT_LOGD("Failed to lookup function name (ELF): ret=%d", ret);
} else {
ret = bin_info_lookup_dwarf_function_name(bin, addr, &_func_name);
- printf_verbose("Failed to lookup function name (dwarf), error %i\n", ret);
+ BT_LOGD("Failed to lookup function name (DWARF): ret=%d", ret);
}
*func_name = _func_name;
* SOFTWARE.
*/
+#define BT_LOG_TAG "PLUGIN-CTF-LTTNG-UTILS-DEBUG-INFO-FLT"
+#include "logging.h"
+
#include <assert.h>
#include <glib.h>
#include "debug-info.h"
if (!bin->is_elf_only || !debug_info_src->func) {
/* Lookup source location */
ret = bin_info_lookup_source_location(bin, ip, &src_loc);
- printf_verbose("Failed to lookup source location (err: %i)\n", ret);
+ BT_LOGD("Failed to lookup source location: ret=%d", ret);
}
if (src_loc) {
--- /dev/null
+/*
+ * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define BT_LOG_OUTPUT_LEVEL bt_plugin_lttng_utils_debug_info_log_level
+#include <babeltrace/logging-internal.h>
+
+BT_LOG_INIT_LOG_LEVEL(bt_plugin_lttng_utils_debug_info_log_level,
+ "BABELTRACE_PLUGIN_LTTNG_UTILS_DEBUG_INFO_FLT_LOG_LEVEL");
--- /dev/null
+#ifndef PLUGINS_LTTNG_UTILS_DEBUG_INFO_LOGGING_H
+#define PLUGINS_LTTNG_UTILS_DEBUG_INFO_LOGGING_H
+
+/*
+ * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define BT_LOG_OUTPUT_LEVEL bt_plugin_lttng_utils_debug_info_log_level
+#include <babeltrace/logging-internal.h>
+
+BT_LOG_LEVEL_EXTERN_SYMBOL(bt_plugin_lttng_utils_debug_info_log_level);
+
+#endif /* PLUGINS_LTTNG_UTILS_DEBUG_INFO_LOGGING_H */
* SOFTWARE.
*/
+#define BT_LOG_TAG "PLUGIN-CTF-LTTNG-UTILS-DEBUG-INFO-FLT"
+#include "logging.h"
+
#include <babeltrace/graph/notification-iterator.h>
#include <babeltrace/graph/private-notification-iterator.h>
#include <babeltrace/graph/connection.h>
value_ret = bt_value_string_get(value, &tmp);
if (value_ret) {
ret = BT_COMPONENT_STATUS_INVALID;
- printf_error("Failed to retrieve debug-info-field-name value. "
+ BT_LOGE_STR("Failed to retrieve debug-info-field-name value. "
"Expecting a string");
}
strcpy(debug_info_component->arg_debug_info_field_name, tmp);
malloc(strlen("debug_info") + 1);
if (!debug_info_component->arg_debug_info_field_name) {
ret = BT_COMPONENT_STATUS_NOMEM;
- printf_error();
+ BT_LOGE_STR("Missing field name.");
}
sprintf(debug_info_component->arg_debug_info_field_name,
"debug_info");
&debug_info_component->arg_debug_dir);
if (value_ret) {
ret = BT_COMPONENT_STATUS_INVALID;
- printf_error("Failed to retrieve debug-dir value. "
+ BT_LOGE_STR("Failed to retrieve debug-dir value. "
"Expecting a string");
}
}
&debug_info_component->arg_target_prefix);
if (value_ret) {
ret = BT_COMPONENT_STATUS_INVALID;
- printf_error("Failed to retrieve target-prefix value. "
+ BT_LOGE_STR("Failed to retrieve target-prefix value. "
"Expecting a string");
}
}
&bool_val);
if (value_ret) {
ret = BT_COMPONENT_STATUS_INVALID;
- printf_error("Failed to retrieve full-path value. "
+ BT_LOGE_STR("Failed to retrieve full-path value. "
"Expecting a boolean");
}
if !BUILT_IN_PLUGINS
libbabeltrace_plugin_text_la_LIBADD += \
$(top_builddir)/lib/libbabeltrace.la \
- $(top_builddir)/common/libbabeltrace-common.la
+ $(top_builddir)/common/libbabeltrace-common.la \
+ $(top_builddir)/logging/libbabeltrace-logging.la
endif
copy.c \
trimmer.h \
iterator.h \
- copy.h
+ copy.h \
+ logging.c \
+ logging.h
libbabeltrace_plugin_trimmer_la_LIBADD =
if !BUILT_IN_PLUGINS
libbabeltrace_plugin_trimmer_la_LIBADD += \
- $(top_builddir)/plugins/libctfcopytrace/libctfcopytrace.la
+ $(top_builddir)/plugins/libctfcopytrace/libctfcopytrace.la \
+ $(top_builddir)/common/libbabeltrace-common.la \
+ $(top_builddir)/logging/libbabeltrace-logging.la
endif
* SOFTWARE.
*/
+#define BT_LOG_TAG "PLUGIN-UTILS-TRIMMER-FLT"
+#include "logging.h"
+
#include <babeltrace/compat/time-internal.h>
#include <babeltrace/compat/utc-internal.h>
#include <babeltrace/graph/notification-iterator.h>
if (bound->lazy_values.gmt) {
/* Get day, month, year. */
if (!bt_gmtime_r(&timeval, &tm)) {
- printf_error("Failure in bt_gmtime_r()");
+ BT_LOGE_STR("Failure in bt_gmtime_r()");
goto error;
}
tm.tm_sec = bound->lazy_values.ss;
tm.tm_hour = bound->lazy_values.hh;
timeval = bt_timegm(&tm);
if (timeval < 0) {
- printf_error("Failure in bt_timegm(), incorrectly formatted %s timestamp",
+ BT_LOGE("Failure in bt_timegm(), incorrectly formatted %s timestamp",
name);
goto error;
}
} else {
/* Get day, month, year. */
if (!bt_localtime_r(&timeval, &tm)) {
- printf_error("Failure in bt_localtime_r()");
+ BT_LOGE_STR("Failure in bt_localtime_r()");
goto error;
}
tm.tm_sec = bound->lazy_values.ss;
tm.tm_hour = bound->lazy_values.hh;
timeval = mktime(&tm);
if (timeval < 0) {
- printf_error("Failure in mktime(), incorrectly formatted %s timestamp",
+ BT_LOGE("Failure in mktime(), incorrectly formatted %s timestamp",
name);
goto error;
}
clock_value = bt_ctf_event_get_clock_value(event, clock_class);
if (!clock_value) {
- printf_error("Failed to retrieve clock value");
+ BT_LOGE_STR("Failed to retrieve clock value");
goto error;
}
clock_ret = bt_ctf_clock_value_get_value_ns_from_epoch(
clock_value, &ts);
if (clock_ret) {
- printf_error("Failed to retrieve clock value timestamp");
+ BT_LOGE_STR("Failed to retrieve clock value timestamp");
goto error;
}
if (update_lazy_bound(begin, "begin", ts, &lazy_update)) {
}
if (lazy_update && begin->set && end->set) {
if (begin->value > end->value) {
- printf_error("Unexpected: time range begin value is above end value");
+ BT_LOGE_STR("Unexpected: time range begin value is above end value");
goto error;
}
}
}
if (lazy_update && begin->set && end->set) {
if (begin->value > end->value) {
- printf_error("Unexpected: time range begin value is above end value");
+ BT_LOGE_STR("Unexpected: time range begin value is above end value");
goto end_no_notif;
}
}
--- /dev/null
+/*
+ * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define BT_LOG_OUTPUT_LEVEL bt_plugin_utils_trimmer_log_level
+#include <babeltrace/logging-internal.h>
+
+BT_LOG_INIT_LOG_LEVEL(bt_plugin_utils_trimmer_log_level,
+ "BABELTRACE_PLUGIN_UTILS_TRIMMER_FLT_LOG_LEVEL");
--- /dev/null
+#ifndef PLUGINS_UTILS_TRIMMER_LOGGING_H
+#define PLUGINS_UTILS_TRIMMER_LOGGING_H
+
+/*
+ * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define BT_LOG_OUTPUT_LEVEL bt_plugin_utils_trimmer_log_level
+#include <babeltrace/logging-internal.h>
+
+BT_LOG_LEVEL_EXTERN_SYMBOL(bt_plugin_utils_trimmer_log_level);
+
+#endif /* PLUGINS_UTILS_TRIMMER_LOGGING_H */
* SOFTWARE.
*/
+#define BT_LOG_TAG "PLUGIN-UTILS-TRIMMER-FLT"
+#include "logging.h"
+
#include <babeltrace/compat/utc-internal.h>
#include <babeltrace/plugin/plugin-dev.h>
#include <babeltrace/graph/component.h>
value_ret = bt_value_bool_get(value, &gmt);
if (value_ret) {
ret = BT_COMPONENT_STATUS_INVALID;
- printf_error("Failed to retrieve clock-gmt value. Expecting a boolean");
+ BT_LOGE_STR("Failed to retrieve clock-gmt value. Expecting a boolean");
}
}
bt_put(value);
if (value_ret || timestamp_from_arg(str,
trimmer, &trimmer->begin, gmt)) {
ret = BT_COMPONENT_STATUS_INVALID;
- printf_error("Failed to retrieve begin value. Expecting a timestamp string");
+ BT_LOGE_STR("Failed to retrieve begin value. Expecting a timestamp string");
}
}
bt_put(value);
if (value_ret || timestamp_from_arg(str,
trimmer, &trimmer->end, gmt)) {
ret = BT_COMPONENT_STATUS_INVALID;
- printf_error("Failed to retrieve end value. Expecting a timestamp string");
+ BT_LOGE_STR("Failed to retrieve end value. Expecting a timestamp string");
}
}
bt_put(value);
end:
if (trimmer->begin.set && trimmer->end.set) {
if (trimmer->begin.value > trimmer->end.value) {
- printf_error("Unexpected: time range begin value is above end value");
+ BT_LOGE_STR("Unexpected: time range begin value is above end value");
ret = BT_COMPONENT_STATUS_INVALID;
}
}