X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=ntsimulator%2Fntsim-ng%2Futils%2Flog_utils.h;fp=ntsimulator%2Fntsim-ng%2Futils%2Flog_utils.h;h=59fd2770d2078a1c788ed38e3015386e57aa717e;hb=f1d5c9198acde7a7ce296490087cad37e008f688;hp=0000000000000000000000000000000000000000;hpb=f2d8f1002fa93848c80a88e5658db4816cba3020;p=sim%2Fo1-interface.git diff --git a/ntsimulator/ntsim-ng/utils/log_utils.h b/ntsimulator/ntsim-ng/utils/log_utils.h new file mode 100644 index 0000000..59fd277 --- /dev/null +++ b/ntsimulator/ntsim-ng/utils/log_utils.h @@ -0,0 +1,51 @@ +/************************************************************************* +* +* Copyright 2020 highstreet technologies GmbH and others +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +***************************************************************************/ + +#pragma once + +#include +#include + +#define LOG_COLOR_RESET "\033[0m" +#define LOG_COLOR_RED "\033[0;31m" +#define LOG_COLOR_BOLD_RED "\033[1;31m" +#define LOG_COLOR_GREEN "\033[0;32m" +#define LOG_COLOR_BOLD_GREEN "\033[1;32m" +#define LOG_COLOR_YELLOW "\033[0;33m" +#define LOG_COLOR_BOLD_YELLOW "\033[01;33m" +#define LOG_COLOR_BLUE "\033[0;34m" +#define LOG_COLOR_BOLD_BLUE "\033[1;34m" +#define LOG_COLOR_MAGENTA "\033[0;35m" +#define LOG_COLOR_BOLD_MAGENTA "\033[1;35m" +#define LOG_COLOR_CYAN "\033[0;36m" +#define LOG_COLOR_BOLD_CYAN "\033[1;36m" + +#define NTS_ERR_OK (0) +#define NTS_ERR_FAILED (-1) + +void log_init(const char *logfilename); +void log_message(const int verbose_level, const char *format, ...); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wvariadic-macros" +#define log_message(verbose_level, format, args...) log__message(__FILE__, (uint32_t)__LINE__, verbose_level, format, ## args); +#define log_error(format, args...) log__error(__func__, (uint32_t)__LINE__, format, ## args); +#pragma GCC diagnostic pop +void log_close(void); + +//use log_error instead +void log__error(char const * const function, uint32_t location, const char *format, ...); +void log__message(char const * const filename, uint32_t location, const int verbose_level, const char *format, ...);