X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=o-du%2Fphy.git;a=blobdiff_plain;f=fapi_5g%2Fsource%2Finclude%2Fnr5g_fapi_log.h;fp=fapi_5g%2Fsource%2Finclude%2Fnr5g_fapi_log.h;h=8c0a03715221b629d90e222f21c85c68e4747e32;hp=0000000000000000000000000000000000000000;hb=9d66fca5c45c8b3e0d6eab6d51a90c8e9d2614dc;hpb=2fbf70096f64af622da983e88c5a64e90ad9bdbd diff --git a/fapi_5g/source/include/nr5g_fapi_log.h b/fapi_5g/source/include/nr5g_fapi_log.h new file mode 100644 index 0000000..8c0a037 --- /dev/null +++ b/fapi_5g/source/include/nr5g_fapi_log.h @@ -0,0 +1,79 @@ +/****************************************************************************** +* +* Copyright (c) 2019 Intel. +* +* 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. +* +*******************************************************************************/ + +/** + * @file This file consist of fapi logging macro. + * + **/ + +#ifndef NR5G_FAPI_LOG_H_ +#define NR5G_FAPI_LOG_H_ + +#define NR5G_FAPI_STATS_FNAME "FapiStats.txt" + +typedef enum _nr5g_fapi_log_types_t { + INFO_LOG = 0, + DEBUG_LOG, + ERROR_LOG, + TRACE_LOG, + HEXDUMP_LOG, + NONE_LOG // default +} nr5g_fapi_log_types_t; + +extern nr5g_fapi_log_types_t nr5g_fapi_log_level_g; +// get_logger_type_str is utility function, returns logging lever string. +char *get_logger_type_str( + nr5g_fapi_log_types_t e); + +void nr5g_fapi_set_log_level( + nr5g_fapi_log_types_t new_level); + +nr5g_fapi_log_types_t nr5g_fapi_get_log_level( + ); + +// NR5G_FAPI__LOG utility Macro for logging. +#define NR5G_FAPI_LOG(TYPE, MSG) do { \ + if(TYPE == ERROR_LOG) { \ + printf("[NR5G_FAPI][%s]", get_logger_type_str(TYPE)); \ + printf MSG ;\ + printf("\n");\ + } \ + else \ + { \ + if(nr5g_fapi_log_level_g == NONE_LOG) { \ + } \ + else if(TYPE <= nr5g_fapi_log_level_g) { \ + printf("[NR5G_FAPI][%s]", get_logger_type_str(TYPE)); \ + printf MSG ;\ + printf("\n");\ + } \ + else if(TYPE <= nr5g_fapi_log_level_g && TYPE == DEBUG_LOG) { \ + printf("[NR5G_FAPI][%s]", get_logger_type_str(TYPE)); \ + printf MSG ;\ + printf("\n");\ + } \ + else if(TYPE == nr5g_fapi_log_level_g && TYPE == TRACE_LOG) { \ + printf("[NR5G_FAPI][%s]", get_logger_type_str(TYPE)); \ + printf MSG ;\ + printf("\n");\ + } \ + else {}\ + } \ +} while(0) + +#endif // NR5G_FAPI_LOG_H_