-
Notifications
You must be signed in to change notification settings - Fork 7
Merge #171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge #171
Changes from all commits
7f37e75
f584523
acb6cfe
904a916
0d2d9c0
9fae7ea
b8758d4
8b0a25a
ed665ce
8963bce
efcabe1
c093093
faa6b7b
e3be91c
3dcde8e
1e8d64d
22c7e07
b63bb70
ed35f15
f790109
f329d0a
5e13181
359fc04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| /** | ||
| * If not stated otherwise in this file or this component's LICENSE | ||
| * file the following copyright and licenses apply: | ||
| * | ||
| * Copyright 2023 RDK Management | ||
| * | ||
| * 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. | ||
| **/ | ||
|
|
||
| #ifndef RDK_DEBUG_H_ | ||
| #define RDK_DEBUG_H_ | ||
|
|
||
| #include <stdio.h> | ||
|
|
||
|
|
||
| // Try to include the real RDK logger if available | ||
| #ifdef RDK_LOGGER | ||
| // First try to include the real RDK logger header | ||
| #if __has_include(<rdk_logger.h>) | ||
| #include <rdk_logger.h> | ||
| #elif __has_include("rdk_logger.h") | ||
| #include "rdk_logger.h" | ||
| #else | ||
| // If real RDK logger is not available, provide fallback definitions | ||
| #define RDK_LOG_TRACE1 1 | ||
| #define RDK_LOG_DEBUG 2 | ||
| #define RDK_LOG_INFO 3 | ||
| #define RDK_LOG_WARN 4 | ||
| #define RDK_LOG_ERROR 5 | ||
| #define RDK_LOG_FATAL 6 | ||
|
|
||
| // RDK Logger success/failure codes | ||
| #define RDK_SUCCESS 0 | ||
| #define RDK_FAILURE -1 | ||
|
|
||
| // RDK Logger Extended API structures and enums | ||
| typedef enum { | ||
| RDKLOG_OUTPUT_CONSOLE = 1, | ||
| RDKLOG_OUTPUT_FILE = 2 | ||
| } rdklog_output_t; | ||
|
|
||
| typedef enum { | ||
| RDKLOG_FORMAT_SIMPLE = 1, | ||
| RDKLOG_FORMAT_WITH_TS = 2 | ||
| } rdklog_format_t; | ||
|
|
||
| typedef struct { | ||
| char *pModuleName; | ||
| int loglevel; | ||
| rdklog_output_t output; | ||
| rdklog_format_t format; | ||
| void *pFilePolicy; | ||
| } rdk_logger_ext_config_t; | ||
|
|
||
| // Fallback implementations for different RDK logger APIs | ||
| #ifdef RDKB_SUPPORT | ||
| // For RDKB builds, use the old API | ||
| #define RDK_LOGGER_INIT() printf("RDK Logger initialized (fallback)\n") | ||
| #else | ||
| // For non-RDKB builds, use the new extended API | ||
| static inline int rdk_logger_ext_init(rdk_logger_ext_config_t *config) { | ||
| if (config && config->pModuleName) { | ||
| printf("RDK Extended Logger initialized for module: %s (fallback)\n", config->pModuleName); | ||
| } | ||
| return RDK_SUCCESS; | ||
| } | ||
| #endif | ||
|
|
||
| // Fallback RDK_LOG macro that uses printf | ||
| #define RDK_LOG(level, module, ...) \ | ||
| do { \ | ||
| if (level == RDK_LOG_DEBUG) { \ | ||
| printf("DEBUG: %s: ", module); \ | ||
| } \ | ||
| else if (level == RDK_LOG_INFO) { \ | ||
| printf("INFO: %s: ", module); \ | ||
| } \ | ||
| else if (level == RDK_LOG_ERROR) { \ | ||
| printf("ERROR: %s: ", module); \ | ||
| } \ | ||
| else if (level == RDK_LOG_FATAL) { \ | ||
| printf("FATAL: %s: ", module); \ | ||
| } \ | ||
| printf(__VA_ARGS__); \ | ||
| } while (0) | ||
| #endif | ||
| #else | ||
| // When RDK_LOGGER is not defined, provide minimal definitions | ||
| #define RDK_LOG_TRACE1 1 | ||
| #define RDK_LOG_DEBUG 2 | ||
| #define RDK_LOG_INFO 3 | ||
| #define RDK_LOG_WARN 4 | ||
| #define RDK_LOG_ERROR 5 | ||
| #define RDK_LOG_FATAL 6 | ||
|
|
||
| #define RDK_SUCCESS 0 | ||
| #define RDK_FAILURE -1 | ||
|
|
||
| #define RDK_LOGGER_INIT() ; | ||
|
|
||
| typedef enum { | ||
| RDKLOG_OUTPUT_CONSOLE = 1, | ||
| RDKLOG_OUTPUT_FILE = 2 | ||
| } rdklog_output_t; | ||
|
|
||
| typedef enum { | ||
| RDKLOG_FORMAT_SIMPLE = 1, | ||
| RDKLOG_FORMAT_WITH_TS = 2 | ||
| } rdklog_format_t; | ||
|
|
||
| typedef struct { | ||
| char *pModuleName; | ||
| int loglevel; | ||
| rdklog_output_t output; | ||
| rdklog_format_t format; | ||
| void *pFilePolicy; | ||
| } rdk_logger_ext_config_t; | ||
|
|
||
| static inline int rdk_logger_ext_init(rdk_logger_ext_config_t *config) { | ||
| (void)config; // Suppress unused parameter warning | ||
| return RDK_SUCCESS; | ||
| } | ||
|
|
||
| // Simple printf-based logging when RDK_LOGGER is not enabled | ||
| #define RDK_LOG(level, module, ...) \ | ||
| do { \ | ||
| printf("[%s] ", module); \ | ||
| printf(__VA_ARGS__); \ | ||
| } while (0) | ||
| #endif | ||
|
|
||
| #endif // RDK_DEBUG_H_ |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -39,9 +39,25 @@ namespace rfc { | |||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||
| RFCManager ::RFCManager() { | ||||||||||||||||||||||||||||
| #if defined(RDK_LOGGER) | ||||||||||||||||||||||||||||
| #if defined(RDKB_SUPPORT) | ||||||||||||||||||||||||||||
| RDK_LOGGER_INIT(); | ||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||
| /* Initialize RDK Logger */ | ||||||||||||||||||||||||||||
| rdk_logger_init(0 == access(OVERIDE_DEBUG_INI_FILE, R_OK) ? OVERIDE_DEBUG_INI_FILE : DEBUG_INI_FILE); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| static char RFCMGRLOG[] = "LOG.RDK.RFCMGR"; | ||||||||||||||||||||||||||||
| rdk_logger_ext_config_t config = { | ||||||||||||||||||||||||||||
| .pModuleName = RFCMGRLOG, /* Module name */ | ||||||||||||||||||||||||||||
| .loglevel = RDK_LOG_INFO, /* Default log level */ | ||||||||||||||||||||||||||||
| .output = RDKLOG_OUTPUT_CONSOLE, /* Output to console (stdout/stderr) */ | ||||||||||||||||||||||||||||
| .format = RDKLOG_FORMAT_WITH_TS, /* Timestamped format */ | ||||||||||||||||||||||||||||
| .pFilePolicy = NULL /* Not using file output, so NULL */ | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
|
Comment on lines
+48
to
+54
|
||||||||||||||||||||||||||||
| rdk_logger_ext_config_t config = { | |
| .pModuleName = RFCMGRLOG, /* Module name */ | |
| .loglevel = RDK_LOG_INFO, /* Default log level */ | |
| .output = RDKLOG_OUTPUT_CONSOLE, /* Output to console (stdout/stderr) */ | |
| .format = RDKLOG_FORMAT_WITH_TS, /* Timestamped format */ | |
| .pFilePolicy = NULL /* Not using file output, so NULL */ | |
| }; | |
| rdk_logger_ext_config_t config{}; | |
| config.pModuleName = RFCMGRLOG; /* Module name */ | |
| config.loglevel = RDK_LOG_INFO; /* Default log level */ | |
| config.output = RDKLOG_OUTPUT_CONSOLE; /* Output to console (stdout/stderr) */ | |
| config.format = RDKLOG_FORMAT_WITH_TS; /* Timestamped format */ | |
| config.pFilePolicy = NULL; /* Not using file output, so NULL */ |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rfcMgr_gtest builds rfc_manager.cpp but the gtest Makefile does not link -lrdkloggers. Introducing a direct call to rdk_logger_ext_init() is therefore likely to break unit-test linking (the symbol is not provided anywhere in this repo). Consider guarding this call under #if !defined(GTEST_ENABLE) and/or providing a test stub, or update the gtest target’s link flags accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static char RFCMGRLOG[] = "LOG.RDK.RFCMGR";is not modified anywhere and can bestatic const char*(orconstexpr const char[]) to avoid exposing a writable buffer unnecessarily.