static const char* log_level_env_var_names[] = {
"BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL",
"BABELTRACE_PYTHON_BT2_LOG_LEVEL",
- "BABELTRACE_SINK_CTF_FS_LOG_LEVEL",
"BABELTRACE_SINK_TEXT_DETAILS_LOG_LEVEL",
"BABELTRACE_SRC_CTF_FS_LOG_LEVEL",
NULL,
libbabeltrace2_plugin_ctf_fs_sink_la_SOURCES = \
fs-sink.c \
fs-sink.h \
- logging.c \
- logging.h \
fs-sink-ctf-meta.h \
translate-trace-ir-to-ctf-ir.c \
translate-trace-ir-to-ctf-ir.h \
* SOFTWARE.
*/
+#define BT_LOG_OUTPUT_LEVEL (stream->log_level)
#define BT_LOG_TAG "PLUGIN/SINK.CTF.FS/STREAM"
-#include "logging.h"
+#include "logging/log.h"
#include <babeltrace2/babeltrace.h>
#include <stdio.h>
goto end;
}
+ stream->log_level = trace->log_level;
stream->trace = trace;
stream->ir_stream = ir_stream;
stream->packet_state.beginning_cs = UINT64_C(-1);
stream->prev_packet_state.discarded_events_counter = UINT64_C(-1);
stream->prev_packet_state.seq_num = UINT64_C(-1);
ret = try_translate_stream_class_trace_ir_to_ctf_ir(trace->tc,
- bt_stream_borrow_class_const(ir_stream), &stream->sc);
+ bt_stream_borrow_class_const(ir_stream), &stream->sc,
+ stream->log_level);
if (ret) {
goto error;
}
set_stream_file_name(stream);
g_string_append_printf(path, "/%s", stream->file_name->str);
- ret = bt_ctfser_init(&stream->ctfser, path->str, BT_LOG_OUTPUT_LEVEL);
+ ret = bt_ctfser_init(&stream->ctfser, path->str,
+ stream->log_level);
if (ret) {
goto error;
}
struct fs_sink_trace;
struct fs_sink_stream {
+ bt_logging_level log_level;
struct fs_sink_trace *trace;
struct bt_ctfser ctfser;
* SOFTWARE.
*/
+#define BT_LOG_OUTPUT_LEVEL (trace->log_level)
#define BT_LOG_TAG "PLUGIN/SINK.CTF.FS/TRACE"
-#include "logging.h"
+#include "logging/log.h"
#include <babeltrace2/babeltrace.h>
#include <stdio.h>
*/
static
-int lttng_validate_datetime(const char *datetime)
+int lttng_validate_datetime(const struct fs_sink_trace *trace,
+ const char *datetime)
{
GTimeVal tv;
int ret = -1;
}
static
-int append_lttng_trace_path_ust_uid(GString *path, const bt_trace_class *tc)
+int append_lttng_trace_path_ust_uid(const struct fs_sink_trace *trace,
+ GString *path, const bt_trace_class *tc)
{
const bt_value *v;
int ret;
}
static
-int append_lttng_trace_path_ust_pid(GString *path, const bt_trace_class *tc)
+int append_lttng_trace_path_ust_pid(const struct fs_sink_trace *trace,
+ GString *path, const bt_trace_class *tc)
{
const bt_value *v;
const char *datetime;
datetime = bt_value_string_get(v);
- if (lttng_validate_datetime(datetime)) {
+ if (lttng_validate_datetime(trace, datetime)) {
goto error;
}
datetime = bt_value_string_get(v);
- if (lttng_validate_datetime(datetime)) {
+ if (lttng_validate_datetime(trace, datetime)) {
goto error;
}
g_string_append_printf(path, G_DIR_SEPARATOR_S "%s", tracer_buffering_scheme);
if (g_str_equal(tracer_buffering_scheme, "uid")) {
- if (append_lttng_trace_path_ust_uid(path, tc)) {
+ if (append_lttng_trace_path_ust_uid(trace, path, tc)) {
goto error;
}
} else if (g_str_equal(tracer_buffering_scheme, "pid")){
- if (append_lttng_trace_path_ust_pid(path, tc)) {
+ if (append_lttng_trace_path_ust_pid(trace, path, tc)) {
goto error;
}
} else {
goto end;
}
+ trace->log_level = fs_sink->log_level;
trace->fs_sink = fs_sink;
trace->ir_trace = ir_trace;
trace->ir_trace_destruction_listener_id = UINT64_C(-1);
trace->tc = translate_trace_class_trace_ir_to_ctf_ir(
- bt_trace_borrow_class_const(ir_trace));
+ bt_trace_borrow_class_const(ir_trace),
+ fs_sink->log_level);
if (!trace->tc) {
goto error;
}
struct fs_sink_comp;
struct fs_sink_trace {
+ bt_logging_level log_level;
struct fs_sink_comp *fs_sink;
/* Owned by this */
* SOFTWARE.
*/
+#define BT_LOG_OUTPUT_LEVEL (fs_sink->log_level)
#define BT_LOG_TAG "PLUGIN/SINK.CTF.FS"
-#include "logging.h"
+#include "logging/log.h"
#include <babeltrace2/babeltrace.h>
#include <stdio.h>
BT_HIDDEN
bt_self_component_status ctf_fs_sink_init(
- bt_self_component_sink *self_comp, const bt_value *params,
+ bt_self_component_sink *self_comp_sink, const bt_value *params,
void *init_method_data)
{
bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
struct fs_sink_comp *fs_sink = NULL;
+ bt_self_component *self_comp =
+ bt_self_component_sink_as_self_component(self_comp_sink);
+ bt_logging_level log_level = bt_component_get_logging_level(
+ bt_self_component_as_component(self_comp));
fs_sink = g_new0(struct fs_sink_comp, 1);
if (!fs_sink) {
- BT_LOGE_STR("Failed to allocate one CTF FS sink structure.");
+ BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG,
+ "Failed to allocate one CTF FS sink structure.");
status = BT_SELF_COMPONENT_STATUS_NOMEM;
goto end;
}
+ fs_sink->log_level = log_level;
fs_sink->output_dir_path = g_string_new(NULL);
- fs_sink->self_comp = self_comp;
+ fs_sink->self_comp = self_comp_sink;
status = configure_component(fs_sink, params);
if (status != BT_SELF_COMPONENT_STATUS_OK) {
/* configure_component() logs errors */
goto end;
}
- status = bt_self_component_sink_add_input_port(self_comp, in_port_name,
- NULL, NULL);
+ status = bt_self_component_sink_add_input_port(self_comp_sink,
+ in_port_name, NULL, NULL);
if (status != BT_SELF_COMPONENT_STATUS_OK) {
goto end;
}
- bt_self_component_set_data(
- bt_self_component_sink_as_self_component(self_comp), fs_sink);
+ bt_self_component_set_data(self_comp, fs_sink);
end:
if (status != BT_SELF_COMPONENT_STATUS_OK) {
}
ret = try_translate_event_class_trace_ir_to_ctf_ir(stream->sc,
- bt_event_borrow_class_const(ir_event), &ec);
+ bt_event_borrow_class_const(ir_event), &ec,
+ fs_sink->log_level);
if (ret) {
status = BT_SELF_COMPONENT_STATUS_ERROR;
goto end;
#include <glib.h>
struct fs_sink_comp {
+ bt_logging_level log_level;
bt_self_component_sink *self_comp;
/* Owned by this */
+++ /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_fs_sink_log_level
-#include "logging/log.h"
-
-BT_LOG_INIT_LOG_LEVEL(bt_plugin_fs_sink_log_level,
- "BABELTRACE_SINK_CTF_FS_LOG_LEVEL");
+++ /dev/null
-#ifndef PLUGINS_FS_SINK_LOGGING_H
-#define PLUGINS_FS_SINK_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_fs_sink_log_level
-#include "logging/log.h"
-
-BT_LOG_LEVEL_EXTERN_SYMBOL(bt_plugin_fs_sink_log_level);
-
-#endif /* PLUGINS_FS_SINK_LOGGING_H */
* SOFTWARE.
*/
-#define BT_LOG_TAG "PLUGIN/SINK.CTF.FS/TRANSLATE-CTF-IR-TO-TSDL"
-#include "logging.h"
-
#include <babeltrace2/babeltrace.h>
#include "common/macros.h"
#include <stdio.h>
* SOFTWARE.
*/
+#define BT_LOG_OUTPUT_LEVEL (ctx->log_level)
#define BT_LOG_TAG "PLUGIN/SINK.CTF.FS/TRANSLATE-TRACE-IR-TO-CTF-IR"
-#include "logging.h"
+#include "logging/log.h"
#include <babeltrace2/babeltrace.h>
#include "common/macros.h"
};
struct ctx {
+ bt_logging_level log_level;
+
/* Weak */
struct fs_sink_ctf_stream_class *cur_sc;
}
static inline
-void ctx_init(struct ctx *ctx)
+void ctx_init(struct ctx *ctx, bt_logging_level log_level)
{
memset(ctx, 0, sizeof(struct ctx));
ctx->cur_path = g_array_new(FALSE, TRUE,
sizeof(struct field_path_elem));
BT_ASSERT(ctx->cur_path);
+ ctx->log_level = log_level;
}
static inline
static
int translate_event_class(struct fs_sink_ctf_stream_class *sc,
const bt_event_class *ir_ec,
- struct fs_sink_ctf_event_class **out_ec)
+ struct fs_sink_ctf_event_class **out_ec,
+ bt_logging_level log_level)
{
int ret = 0;
struct ctx ctx;
BT_ASSERT(sc);
BT_ASSERT(ir_ec);
- ctx_init(&ctx);
+ ctx_init(&ctx, log_level);
ec = fs_sink_ctf_event_class_create(sc, ir_ec);
BT_ASSERT(ec);
ctx.cur_sc = sc;
int try_translate_event_class_trace_ir_to_ctf_ir(
struct fs_sink_ctf_stream_class *sc,
const bt_event_class *ir_ec,
- struct fs_sink_ctf_event_class **out_ec)
+ struct fs_sink_ctf_event_class **out_ec,
+ bt_logging_level log_level)
{
int ret = 0;
goto end;
}
- ret = translate_event_class(sc, ir_ec, out_ec);
+ ret = translate_event_class(sc, ir_ec, out_ec, log_level);
end:
return ret;
static
int translate_stream_class(struct fs_sink_ctf_trace_class *tc,
const bt_stream_class *ir_sc,
- struct fs_sink_ctf_stream_class **out_sc)
+ struct fs_sink_ctf_stream_class **out_sc,
+ bt_logging_level log_level)
{
int ret = 0;
struct ctx ctx;
BT_ASSERT(tc);
BT_ASSERT(ir_sc);
- ctx_init(&ctx);
+ ctx_init(&ctx, log_level);
*out_sc = fs_sink_ctf_stream_class_create(tc, ir_sc);
BT_ASSERT(*out_sc);
int try_translate_stream_class_trace_ir_to_ctf_ir(
struct fs_sink_ctf_trace_class *tc,
const bt_stream_class *ir_sc,
- struct fs_sink_ctf_stream_class **out_sc)
+ struct fs_sink_ctf_stream_class **out_sc,
+ bt_logging_level log_level)
{
int ret = 0;
uint64_t i;
}
}
- ret = translate_stream_class(tc, ir_sc, out_sc);
+ ret = translate_stream_class(tc, ir_sc, out_sc, log_level);
end:
return ret;
BT_HIDDEN
struct fs_sink_ctf_trace_class *translate_trace_class_trace_ir_to_ctf_ir(
- const bt_trace_class *ir_tc)
+ const bt_trace_class *ir_tc, bt_logging_level log_level)
{
uint64_t count;
uint64_t i;
ir_tc, i, &name, &val);
if (!fs_sink_ctf_ist_valid_identifier(name)) {
- BT_LOGE("Unsupported trace class's environment entry name: "
+ BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level,
+ BT_LOG_TAG,
+ "Unsupported trace class's environment entry name: "
"name=\"%s\"", name);
goto end;
}
case BT_VALUE_TYPE_STRING:
break;
default:
- BT_LOGE("Unsupported trace class's environment entry value type: "
+ BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level,
+ BT_LOG_TAG,
+ "Unsupported trace class's environment entry value type: "
"type=%s",
bt_common_value_type_string(
bt_value_get_type(val)));
int try_translate_event_class_trace_ir_to_ctf_ir(
struct fs_sink_ctf_stream_class *sc,
const bt_event_class *ir_ec,
- struct fs_sink_ctf_event_class **out_ec);
+ struct fs_sink_ctf_event_class **out_ec,
+ bt_logging_level log_level);
BT_HIDDEN
int try_translate_stream_class_trace_ir_to_ctf_ir(
struct fs_sink_ctf_trace_class *tc,
const bt_stream_class *ir_sc,
- struct fs_sink_ctf_stream_class **out_sc);
+ struct fs_sink_ctf_stream_class **out_sc,
+ bt_logging_level log_level);
BT_HIDDEN
struct fs_sink_ctf_trace_class *translate_trace_class_trace_ir_to_ctf_ir(
- const bt_trace_class *ir_tc);
+ const bt_trace_class *ir_tc, bt_logging_level log_level);
#endif /* BABELTRACE_PLUGIN_CTF_FS_SINK_TRANSLATE_TRACE_IR_TO_CTF_IR_H */