From ea9f8b298e259ae01504091093fcf3d1edf6b3b8 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Wed, 31 May 2017 14:32:36 -0400 Subject: [PATCH] cli: use standard logging files and macros MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- cli/Makefile.am | 2 +- cli/babeltrace.c | 9 +++------ cli/logging.c | 26 ++++++++++++++++++++++++++ cli/logging.h | 8 ++------ 4 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 cli/logging.c diff --git a/cli/Makefile.am b/cli/Makefile.am index 5f07bf19..c45ecd2c 100644 --- a/cli/Makefile.am +++ b/cli/Makefile.am @@ -25,7 +25,7 @@ babeltrace_bin_SOURCES = \ babeltrace-cfg-cli-args-connect.h \ babeltrace-cfg-cli-args-default.h \ babeltrace-cfg-cli-args-default.c \ - logging.h + logging.c logging.h # -Wl,--no-as-needed is needed for recent gold linker who seems to think # it knows better and considers libraries with constructors having diff --git a/cli/babeltrace.c b/cli/babeltrace.c index fbf61141..8e4755a6 100644 --- a/cli/babeltrace.c +++ b/cli/babeltrace.c @@ -26,6 +26,9 @@ * SOFTWARE. */ +#define BT_LOG_TAG "CLI" +#include "logging.h" + #include #include #include @@ -54,9 +57,6 @@ #include "babeltrace-cfg-cli-args.h" #include "babeltrace-cfg-cli-args-default.h" -#define BT_LOG_TAG "CLI" -#include "logging.h" - #define ENV_BABELTRACE_WARN_COMMAND_NAME_DIRECTORY_CLASH "BABELTRACE_CLI_WARN_COMMAND_NAME_DIRECTORY_CLASH" /* Application's processing graph (weak) */ @@ -65,9 +65,6 @@ static bool canceled = false; GPtrArray *loaded_plugins; -BT_HIDDEN -int bt_cli_log_level = BT_LOG_NONE; - static void sigint_handler(int signum) { diff --git a/cli/logging.c b/cli/logging.c new file mode 100644 index 00000000..52d531c7 --- /dev/null +++ b/cli/logging.c @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2017 Philippe Proulx + * + * 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_cli_log_level +#include + +BT_LOG_INIT_LOG_LEVEL(bt_cli_log_level, "BABELTRACE_CLI_LOG_LEVEL"); diff --git a/cli/logging.h b/cli/logging.h index b1aee09f..ccc6c527 100644 --- a/cli/logging.h +++ b/cli/logging.h @@ -2,7 +2,7 @@ #define CLI_LOGGING_H /* - * Copyright 2017 Philippe Proulx + * Copyright (c) 2017 Philippe Proulx * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,13 +23,9 @@ * SOFTWARE. */ -#include - #define BT_LOG_OUTPUT_LEVEL bt_cli_log_level - #include -BT_HIDDEN -int bt_cli_log_level; +BT_LOG_LEVEL_EXTERN_SYMBOL(bt_cli_log_level); #endif /* CLI_LOGGING_H */ -- 2.34.1