X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fplugins%2Fctf%2Fcommon%2Fmetadata%2Flogging.h;h=4488b620b40d67989ca3ed2e9d8c76a6e0ab34fd;hb=50f6fce8d00bc6b70a814a0be3b71570fb65d070;hp=dbd00474048ac004e7c74d884784724dca66e6c7;hpb=0746848ce8b40484254eeace3962a7654d01c7bc;p=babeltrace.git diff --git a/src/plugins/ctf/common/metadata/logging.h b/src/plugins/ctf/common/metadata/logging.h index dbd00474..4488b620 100644 --- a/src/plugins/ctf/common/metadata/logging.h +++ b/src/plugins/ctf/common/metadata/logging.h @@ -1,28 +1,13 @@ -#ifndef CTF_METADATA_LOGGING_H -#define CTF_METADATA_LOGGING_H - /* - * Copyright (c) 2017 Jérémie Galarneau - * - * 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: + * SPDX-License-Identifier: MIT * - * 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. + * Copyright (c) 2017 Jérémie Galarneau */ +#ifndef CTF_METADATA_LOGGING_H +#define CTF_METADATA_LOGGING_H + +#include #include "logging/log.h" /* @@ -31,13 +16,47 @@ */ BT_LOG_LEVEL_EXTERN_SYMBOL(ctf_plugin_metadata_log_level); -#define _BT_LOGV_LINENO(_lineno, _msg, args...) \ - BT_LOGV("At line %u in metadata stream: " _msg, _lineno, ## args) +/* + * To be used by functions without a context structure to pass all the + * logging configuration at once. + */ +struct meta_log_config { + bt_logging_level log_level; + + /* Weak, exactly one of these must be set */ + bt_self_component *self_comp; + bt_self_component_class *self_comp_class; +}; + +#define _BT_LOGT_LINENO(_lineno, _msg, args...) \ + BT_LOGT("At line %u in metadata stream: " _msg, _lineno, ## args) #define _BT_LOGW_LINENO(_lineno, _msg, args...) \ BT_LOGW("At line %u in metadata stream: " _msg, _lineno, ## args) -#define _BT_LOGE_LINENO(_lineno, _msg, args...) \ - BT_LOGE("At line %u in metadata stream: " _msg, _lineno, ## args) +#define _BT_LOGE_APPEND_CAUSE_LINENO(_lineno, _msg, args...) \ + do { \ + BT_LOGE("At line %u in metadata stream: " _msg, _lineno, ## args); \ + (void) BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN( \ + "CTF metadata parser", "At line %u in metadata stream: " _msg, _lineno, ## args); \ + } while (0) + +#define _BT_COMP_LOGT_LINENO(_lineno, _msg, args...) \ + BT_COMP_LOGT("At line %u in metadata stream: " _msg, _lineno, ## args) + +#define _BT_COMP_LOGW_LINENO(_lineno, _msg, args...) \ + BT_COMP_LOGW("At line %u in metadata stream: " _msg, _lineno, ## args) + +#define _BT_COMP_LOGE_LINENO(_lineno, _msg, args...) \ + BT_COMP_LOGE("At line %u in metadata stream: " _msg, _lineno, ## args) + +#define _BT_COMP_LOGE_APPEND_CAUSE_LINENO(_lineno, _msg, args...) \ + BT_COMP_LOGE_APPEND_CAUSE(BT_COMP_LOG_SELF_COMP, "At line %u in metadata stream: " _msg, _lineno, ## args) + +#define _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(_msg, args...) \ + BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE( \ + BT_COMP_LOG_SELF_COMP, \ + BT_COMP_LOG_SELF_COMP_CLASS, \ + _msg, ## args) #endif /* CTF_METADATA_LOGGING_H */