-
Notifications
You must be signed in to change notification settings - Fork 6
RDKB-63483: RFC Fix L1 Issues with new logger api #175
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0d2d9c0
Merge pull request #174 from rdkcentral/develop
nhanasi 9fae7ea
Create rdk_debug.h
nhanasi b8758d4
Update rfc_manager.cpp
nhanasi 8b0a25a
Apply suggestion from @Copilot
nhanasi ed665ce
Initial plan
Copilot 8963bce
Add RDK_LOG_FATAL definition to fallback log levels
Copilot efcabe1
Final verification complete
Copilot c093093
Add .gitignore and remove build artifacts
Copilot faa6b7b
Merge pull request #177 from rdkcentral/copilot/sub-pr-175-again
nhanasi e3be91c
Apply suggestion from @Copilot
nhanasi 3dcde8e
Apply suggestion from @Copilot
nhanasi 1e8d64d
Update run_l2.sh
nhanasi 22c7e07
Delete .gitignore
nhanasi b63bb70
Update run_l2.sh
nhanasi ed35f15
Update rfc_manager.cpp
nhanasi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| /** | ||
|
Check failure on line 1 in rfcMgr/rdk_debug.h
|
||
| * 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> | ||
|
|
||
| #define LOG_RFCMGR "LOG.RDK.RFCMGR" | ||
|
|
||
| // 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") | ||
nhanasi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #include "rdk_logger.h" | ||
| #else | ||
| // If real RDK logger is not available, provide fallback definitions | ||
nhanasi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #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 | ||
nhanasi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // 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") | ||
nhanasi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #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 | ||
nhanasi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // 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); \ | ||
| } \ | ||
| printf(__VA_ARGS__); \ | ||
| } while (0) | ||
nhanasi marked this conversation as resolved.
Show resolved
Hide resolved
nhanasi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #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 | ||
nhanasi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| #define RDK_SUCCESS 0 | ||
| #define RDK_FAILURE -1 | ||
|
|
||
| #define RDK_LOGGER_INIT() ; | ||
nhanasi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| typedef struct { | ||
| char *pModuleName; | ||
| int loglevel; | ||
| int output; | ||
| int format; | ||
nhanasi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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); \ | ||
nhanasi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| printf(__VA_ARGS__); \ | ||
| } while (0) | ||
| #endif | ||
|
|
||
| #endif // RDK_DEBUG_H_ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.