Skip to content
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

Update logging mechanism with LOG macro in multiple classes #250

Merged
merged 5 commits into from
Oct 24, 2024

Conversation

forntoh
Copy link
Owner

@forntoh forntoh commented Oct 23, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a streamlined logging mechanism by replacing printLog with LOG across various classes, enhancing consistency in logging practices.
  • Bug Fixes

    • No significant bug fixes were reported in this release.
  • Documentation

    • Updated internal documentation to reflect changes in logging functionality and usage.
  • Refactor

    • Consolidated logging functionality into a new log function with template support, improving flexibility for logging different types.
  • Chores

    • Cleaned up unused logging function overloads to simplify the codebase.

Checklist

General Requirements

  • I have kept this PR in draft until all the required tasks are completed.
  • I have reviewed the contributing guidelines for this project.
  • I have tagged this PR with breaking-change if it introduces a breaking change.
  • I have checked that this PR does not introduce any breaking changes unless explicitly stated.
  • I have checked that changes generate no new warnings.
  • I have performed a self-review of my own code
  • I have built and tested ALL the examples to ensure that I haven't broken anything.

Refactor/Enhancement

  • This PR is a code refactor.
  • I have tagged this PR with enhancement.
  • I have made changes to the code that improve readability/performance/maintainability.
  • I have added documentation for the changes if necessary.
  • I have generated and reviewed the documentation locally if necessary.

Copy link
Contributor

coderabbitai bot commented Oct 23, 2024

Walkthrough

The changes in this pull request primarily focus on updating the logging mechanism across multiple classes in the codebase. The printLog function has been replaced with a new LOG macro, which calls a more versatile log function defined in src/utils/utils.h. This update affects various classes, including ItemCommand, ItemInput, ItemList, ItemToggle, and others, ensuring consistent logging practices without altering the core functionality or method signatures of the classes.

Changes

File Change Summary
src/ItemCommand.h Renamed printLog to LOG in executeCommand method.
src/ItemInput.h Replaced printLog with LOG in multiple methods (setValue, enter, etc.); initialized view.
src/ItemInputCharset.h Replaced printLog with LOG in process, abortCharEdit, and commitCharEdit methods.
src/ItemList.h Replaced printLog with LOG in process, selectPrevious, and selectNext methods.
src/ItemRangeBase.h Replaced printLog with LOG in increment, decrement, and process methods.
src/ItemSubMenu.h Changed logging from printLog to LOG in changeScreen method (no signature change).
src/ItemToggle.h Renamed printLog to LOG in toggle method.
src/LcdMenu.cpp Renamed printLog to LOG in setScreen method (no change in logic).
src/MenuScreen.cpp Replaced printLog with LOG in process, up, down, and BACK command handling.
src/input/KeyboardAdapter.h Replaced printLog with LOG in handleIdle and handleReceived methods; added reset calls.
src/renderer/MenuRenderer.h Changed logging from printLog to LOG in updateTimer method (no change in logic).
src/utils/utils.h Removed printLog, added log function with templates, and defined LOG macro.
examples/RTOS/RTOS.ino Replaced printLog with LOG in relay toggle functions.
test/Basic.test.yml Updated logging format from : to :: for MenuScreen actions.
test/Callbacks.test.yml Updated logging format from : to :: for MenuScreen actions.
test/IntFloatValues.test.yml Updated logging format from : to :: for MenuScreen actions.
test/ItemBack.test.yml Updated logging format from : to :: for MenuScreen actions.
test/List.test.yml Updated logging format from : to :: for MenuScreen actions.
test/MenuTimeout.test.yml Updated logging format from : to :: for MenuScreen actions.
test/SubMenu.test.yml Updated logging format from : to :: for MenuScreen actions.
test/ViewShifting.test.yml Updated logging format from : to :: for MenuScreen actions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ItemCommand
    participant ItemInput
    participant ItemList
    participant ItemToggle
    participant MenuScreen

    User->>ItemCommand: executeCommand()
    ItemCommand->>ItemInput: setValue()
    ItemInput->>ItemList: process()
    ItemList->>ItemToggle: toggle()
    ItemToggle-->>ItemList: return
    ItemList-->>ItemInput: return
    ItemInput-->>ItemCommand: return
    ItemCommand-->>User: return
Loading

🐇 "In the code where the bunnies hop,
The logs now jump, they never stop.
From printLog to LOG they flew,
A cleaner path for all to view!
With every change, we cheer and play,
Hooray for logs, hip-hip-hooray!" 🐇

Possibly related PRs

  • Add support for additional board types #246: The changes in the main PR regarding the logging function renaming from printLog to LOG are related to the logging mechanism, which is a common theme in the modifications across multiple classes in the retrieved PRs.

Suggested labels

feature


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between ce85443 and b4f958d.

📒 Files selected for processing (1)
  • test/ViewShifting.test.yml (3 hunks)
🔇 Additional comments (2)
test/ViewShifting.test.yml (2)

15-15: LGTM! Consistent logging format updates.

The changes from single colon to double colon in the log messages (MenuScreen::down) are consistent with the new logging mechanism being implemented across the codebase.

Also applies to: 27-27, 37-37


15-15: Verify consistent logging format across test files.

Let's verify that the same logging format changes have been applied consistently across all test files.

Also applies to: 27-27, 37-37

✅ Verification successful

Let me gather more comprehensive information about the logging format across test files to ensure we have a complete view.

This will help us:

  1. See the complete context of MenuScreen logging patterns
  2. Identify if there are other components using logging that we should verify for consistency

Based on the comprehensive results, I can now provide the final response:

All test files consistently use the double-colon format

The verification shows that all log messages across test files follow the consistent double-colon (::) format. This includes:

  • MenuScreen logging (e.g., #LOG# MenuScreen::down=1)
  • Other components like LcdMenu, ItemList, ItemSubMenu, etc.
  • No instances of single-colon format were found
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify logging format consistency across test files
# Expected: All log messages should use double colons (::) instead of single colon (:)

echo "Checking for any remaining single-colon log formats in test files..."
rg -g '*.test.yml' '#LOG#.*MenuScreen:[^:]' test/

if [ $? -eq 0 ]; then
    echo "Found test files still using old single-colon format"
    exit 1
else
    echo "All test files are using the new double-colon format"
fi

Length of output: 331


Script:

#!/bin/bash
# Let's check all log message formats in test files to ensure consistency
echo "Checking all LOG patterns in test files..."
rg -g '*.test.yml' '#LOG#.*MenuScreen' test/ -A 1

# Also check if there are any other components using logging to ensure global consistency
echo -e "\nChecking all LOG patterns across all components..."
rg -g '*.test.yml' '#LOG#.*::' test/

Length of output: 18182


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai bot changed the title @coderabbitai Update logging mechanism with LOG macro in multiple classes Oct 23, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 14

🧹 Outside diff range comments (9)
src/ItemCommand.h (1)

Line range hint 1-4: Add missing include for LOG macro.

The file uses the LOG macro but doesn't include the header where it's defined. Based on the AI summary, this should be defined in src/utils/utils.h.

Add this include:

#include "MenuItem.h"
+#include "utils/utils.h"
src/ItemToggle.h (1)

Line range hint 1-107: Consider enhancing type safety and documentation.

While the overall class implementation is solid, here are some suggestions to improve type safety and maintainability:

  1. Use std::function instead of function pointers for callbacks
  2. Add [[nodiscard]] attribute to getter methods
  3. Document thread safety guarantees

Example enhancement for the callback:

#include <functional>

// Replace function pointer typedef with std::function
using ToggleCallback = std::function<bool(bool)>;

// Update member variable
private:
    ToggleCallback callback;
src/MenuScreen.cpp (1)

Line range hint 71-105: Consistent logging implementation across navigation actions.

The logging changes effectively capture navigation events and relevant state information. Consider creating a logging style guide to document these patterns:

  • Class::action format for messages
  • State variables to include in logs
  • Placement of log statements (after state changes)
src/input/KeyboardAdapter.h (1)

Line range hint 224-234: Add error logging for invalid states.

Consider adding logging for error conditions to aid debugging:

             default:
+                LOG(F("KeyboardAdapter: Unknown CSI command received"));
                 reset();  // Reset after unknown code set
                 break;

Similar logging could be added for other error cases where reset() is called.

src/ItemInput.h (5)

Line range hint 183-195: Consider wrapping callback invocation in try-catch.

The callback invocation could throw an exception, which would prevent the logging of the exit action. Consider adding error handling:

 void back(MenuRenderer* renderer) {
     renderer->clearBlinker();
     renderer->setEditMode(false);
     cursor = 0;
     view = 0;
     draw(renderer);
+    try {
         if (callback != NULL) {
             callback(value);
         }
+    } catch (...) {
+        LOG(F("ItemInput::exitEditMode"), F("callback failed"));
+        throw;
+    }
     LOG(F("ItemInput::exitEditMode"), value);
 }

Line range hint 267-291: Fix memory leaks in string manipulation.

The current implementation has potential memory leaks in both branches where dynamically allocated memory is not properly managed.

Consider this safer implementation:

 void typeChar(MenuRenderer* renderer, const unsigned char character) {
     uint8_t length = strlen(value);
     if (cursor < length) {
         char start[length];
         char end[length];
-        char* joined = new char[length + 2];
+        char* newValue = new char[length + 2];
         substring(value, 0, cursor, start);
         substring(value, cursor, length - cursor, end);
         concat(start, character, end, joined);
-        value = joined;
+        delete[] value;  // Clean up old value if heap-allocated
+        value = newValue;
     } else {
-        char* buf = new char[length + 2];
+        char* newValue = new char[length + 2];
         concat(value, character, buf);
-        value = buf;
+        delete[] value;  // Clean up old value if heap-allocated
+        value = newValue;
     }
     cursor++;
     // ... rest of the method
     LOG(F("ItemInput::typeChar"), character);
 }

Line range hint 295-301: Fix potential memory leak in clear method.

Direct assignment of empty string literal could leak memory if the previous value was heap-allocated.

 void clear(MenuRenderer* renderer) {
+    delete[] value;  // Clean up old value if heap-allocated
     value = (char*)"";
     draw(renderer);
     renderer->drawBlinker();
     LOG(F("ItemInput::clear"), value);
 }

Line range hint 1-304: Consider implementing RAII for string management.

The class would benefit from using a proper string management class (like String in Arduino) or implementing RAII principles to handle dynamic memory allocation consistently across all methods.

This would help prevent memory leaks and make the code more maintainable. Consider:

  1. Using Arduino's String class
  2. Creating a custom string wrapper class
  3. Adding a destructor to clean up allocated memory
  4. Implementing copy constructor and assignment operator if needed

Based on the code analysis, I can now provide a final response:

Memory leak confirmed in ItemInput class

The code shows multiple instances of heap allocations without proper cleanup:

  • In typeChar() method:
    char* joined = new char[length + 2];
    // ...
    value = joined;  // Previous value is leaked
  • In ItemInputCharset::commitCharEdit():
    char* buf = new char[length + 2];
    // ...
    value = buf;  // Previous value is leaked

The value member is reassigned without freeing the previous allocation, and there's no destructor to clean up the final allocation. The original review comment's concern is valid.

The suggested fix should be enhanced to:

class ItemInput {
    char* value;
    
    ~ItemInput() {
        delete[] value;
    }
    
    bool setValue(char* newValue) {
        if (this->value != newValue) {
            delete[] this->value;
            this->value = newValue;
            LOG(F("ItemInput::setValue"), newValue);
            return true;
        }
        return false;
    }
};

Additionally, all methods that allocate new strings (typeChar, commitCharEdit) should be reviewed to ensure proper cleanup of the previous value before assignment.

🔗 Analysis chain

Line range hint 95-106: Consider adding memory management for previous value.

If value is heap-allocated, the current implementation could lead to memory leaks when setting new values.

Consider adding proper cleanup:

 bool setValue(char* value) {
     if (this->value != value) {
+        // If previous value was heap-allocated
+        delete[] this->value;
         this->value = value;
         LOG(F("ItemInput::setValue"), value);
         return true;
     }
     return false;
 }

Let me gather more information about how the value is used and allocated in the codebase.

These commands will help us understand:

  1. How the char* value is used across the codebase
  2. Whether there's proper cleanup in the destructor
  3. If there are any heap allocations for char arrays
  4. The complete context of the ItemInput class

This will give us a better picture of the memory management requirements.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if value is heap-allocated elsewhere in the codebase
rg -l "new char\[.+\].*=.*value" 

Length of output: 69


Script:

#!/bin/bash
# Search for any char* allocations or assignments related to ItemInput
rg -A 5 "char\*.*value" 

# Search for constructors and destructor of ItemInput
ast-grep --pattern 'class ItemInput {
  $$$
  ~ItemInput() {
    $$$
  }
  $$$
}'

# Search for any new char[] allocations in the codebase
rg "new char\[" -A 2

# Look for the ItemInput header file to understand the member declaration
fd "ItemInput.h" --exec cat {}

Length of output: 26636

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 3cfaf98 and 991cc30.

📒 Files selected for processing (12)
  • src/ItemCommand.h (1 hunks)
  • src/ItemInput.h (8 hunks)
  • src/ItemInputCharset.h (3 hunks)
  • src/ItemList.h (4 hunks)
  • src/ItemRangeBase.h (4 hunks)
  • src/ItemSubMenu.h (1 hunks)
  • src/ItemToggle.h (1 hunks)
  • src/LcdMenu.cpp (1 hunks)
  • src/MenuScreen.cpp (2 hunks)
  • src/input/KeyboardAdapter.h (2 hunks)
  • src/renderer/MenuRenderer.h (1 hunks)
  • src/utils/utils.h (2 hunks)
🔇 Additional comments (24)
src/ItemSubMenu.h (1)

35-35: LGTM! Verify logging consistency across codebase.

The update to use the LOG macro with the F() macro for flash memory storage is correct and follows best practices.

Let's verify the consistent usage of the new logging mechanism across the codebase:

✅ Verification successful

Let me generate new shell scripts to better verify the logging consistency.

The previous search failed because the path pattern was incorrect. This new set of commands will help us:

  1. Find the actual location and naming of Item-related header files
  2. Check the LOG macro usage across the source files
  3. Verify no printLog calls remain in the source code
  4. Understand the LOG macro definition for context

Logging mechanism has been consistently updated across the codebase

The verification shows that:

  1. No printLog calls remain in the source code (src/ directory)
  2. The LOG macro is consistently used across all menu items with the correct pattern LOG(F("ClassName::methodName"), ...)
  3. The LOG macro is properly defined in src/utils/utils.h with a debug and no-op version
  4. The only remaining printLog references are in example files and keywords.txt, which is acceptable as examples often maintain backward compatibility

The change in ItemSubMenu.h follows the same pattern used throughout the codebase, confirming consistent implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistent usage of LOG macro and absence of printLog
# Expected: Only LOG macro usage, no printLog calls

# Test 1: Check for any remaining printLog calls
echo "Checking for remaining printLog calls..."
rg "printLog"

# Test 2: Verify consistent LOG macro usage pattern in other menu items
echo "Verifying LOG macro usage pattern in menu items..."
rg "LOG\(F\([\"'].*::" "src/Item*.h"

Length of output: 504


Script:

#!/bin/bash
# First, let's find all header files in src directory
echo "Finding all header files in src directory..."
fd -e h -e hpp "^Item.*" src/

# Then, let's check for LOG macro usage in these files
echo "Checking LOG macro usage..."
rg "LOG\(" src/

# Check for any remaining printLog in src directory
echo "Checking for remaining printLog in src..."
rg "printLog" src/

# Get a better context of the logging mechanism
echo "Checking LOG macro definition..."
rg "^#define\s+LOG" -A 2

Length of output: 3719

src/LcdMenu.cpp (2)

12-12: LGTM! Logging standardization looks good.

The change from printLog to LOG is consistent with the codebase-wide logging standardization effort mentioned in the PR summary.


12-12: Verify required includes for LOG and F macros.

The code uses both LOG and F macros, but their includes are not visible in this file.

Let's verify the necessary includes are present:

✅ Verification successful

Let me check the includes in the implementation file and verify if utils.h (which contains LOG macro) is properly included.


Based on the verification results, I can now provide the final response:

LOG and F macros are properly included and available

The necessary includes are properly set up through the include chain:

  • LcdMenu.cpp includes LcdMenu.h
  • LcdMenu.h includes utils/utils.h
  • utils/utils.h includes Arduino.h and defines the LOG macro
  • The F macro is available through the Arduino.h include
  • The LOG macro is properly defined with debug/release configurations
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if LOG and F macros are properly included
echo "Checking for LOG macro definition:"
rg -l "^#define\s+LOG\b" 

echo -e "\nChecking for F macro include or definition:"
rg -l "^#include.*Arduino\.h" 
rg -l "^#define\s+F\b"

echo -e "\nChecking LcdMenu.h for the includes:"
cat src/LcdMenu.h

Length of output: 4494


Script:

#!/bin/bash
# Check LcdMenu.cpp includes
echo "Checking includes in LcdMenu.cpp:"
rg -A 10 "^#include" src/LcdMenu.cpp

# Check utils.h content to verify LOG and F macro definitions
echo -e "\nChecking utils.h content:"
cat src/utils/utils.h

Length of output: 1936

src/utils/utils.h (1)

61-61: Well-structured header file.

The file maintains a clean organization with proper include guards, consistent inline function declarations, and clear debug/release configuration separation.

src/ItemCommand.h (2)

60-60: LGTM! Good logging practice.

The logging implementation:

  • Uses F() macro to store string literal in flash memory (good for Arduino memory optimization)
  • Provides clear context with class::method name
  • Includes the menu item text for better debugging
  • Logs after callback execution for accurate command tracking

60-60: Verify logging pattern consistency.

Let's verify that:

  1. The LOG macro is properly defined
  2. Other files follow the same logging pattern
✅ Verification successful

Based on the results, I can now generate the final response since I have sufficient information about the logging patterns and macro definition.

Logging pattern is consistent across the codebase

The verification shows that:

  1. The LOG macro is properly defined in src/utils/utils.h with two variants:
    • A functional version that calls log()
    • A no-op version for when logging is disabled
  2. The logging pattern LOG(F("ClassName::methodName")) is consistently used across all files, with:
    • Proper class scope prefixing (e.g., ItemCommand::, MenuScreen::, etc.)
    • Consistent use of the F() macro for string literals
    • Optional parameters correctly appended after the message
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check LOG macro definition
echo "Checking LOG macro definition:"
rg -p "^#define\s+LOG" src/

# Check logging pattern consistency
echo -e "\nChecking logging pattern in other files:"
rg "LOG\(F\([\"'].*::" src/

Length of output: 2394

src/ItemToggle.h (1)

105-105: LGTM! Good use of F() macro for flash string optimization.

The change from printLog to LOG maintains logging functionality while properly using the F() macro to store the string literal in flash memory, which is beneficial for memory optimization on embedded systems.

src/MenuScreen.cpp (2)

78-78: LGTM!

The log message appropriately captures both the action and the view shift state.


85-85: LGTM!

The log message maintains consistency with the RIGHT command logging pattern.

src/renderer/MenuRenderer.h (2)

116-116: LGTM! Good use of memory optimization.

The logging change follows the new standardized approach and properly uses the F() macro to store the string in flash memory, which is a good practice for embedded systems.


114-118: Verify logging consistency in derived classes.

Since updateTimer() is virtual, we should ensure derived classes maintain consistent logging if they override this method.

✅ Verification successful

Let me try a different approach to verify the derived classes and logging patterns.

This should give us:

  1. All classes that inherit from MenuRenderer
  2. All implementations of updateTimer
  3. The logging pattern usage across the codebase to verify consistency

Based on the results, I can now generate the final response:

Logging pattern is consistent, no derived class overrides found

The verification results show:

  • updateTimer() is only implemented in the base MenuRenderer class, with no derived class overrides found
  • The LOG(F()) pattern is consistently used across the entire codebase for logging
  • The timeout logging in MenuRenderer::updateTimer() follows the same pattern as other logging statements
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for derived class implementations of updateTimer
ast-grep --pattern 'class $_ : $$$public MenuRenderer$$$ {
  $$$
  void updateTimer() {
    $$$
  }
  $$$
}'

Length of output: 110


Script:

#!/bin/bash
# First, let's find all classes that inherit from MenuRenderer
ast-grep --pattern 'class $_ : $$$MenuRenderer$$$'

# Also search for updateTimer implementations across the codebase
rg "void updateTimer\(\)" -A 5

# And check the logging pattern usage
rg "LOG\(F\(" --type cpp

Length of output: 3212

src/ItemList.h (2)

102-102: LGTM! Logging implementation is correct and efficient.

The LOG call is properly placed after the state changes and uses F() macro for flash string storage optimization.


118-118: LGTM! Logging is consistent with the exit mode pattern.

The LOG call is properly placed after entering edit mode and maintains consistency with other logging calls.

src/ItemRangeBase.h (3)

66-66: LGTM: Logging change in increment method.

The logging change maintains the same semantic meaning while using the new LOG macro.


78-78: LGTM: Logging change in decrement method.

The logging change maintains the same semantic meaning while using the new LOG macro.


66-66: Verify logging implementation across codebase.

Let's verify that the new LOG macro is consistently implemented across the codebase.

Also applies to: 78-78, 125-125, 151-151

✅ Verification successful

Based on the shell script results, I can now generate the final response:

LOG macro implementation is consistent with a few exceptions

The verification reveals:

  • The LOG macro is properly defined in src/utils/utils.h with both debug and no-op variants
  • Most of the codebase consistently uses LOG(F(...)) pattern for logging
  • There are 3 remaining legacy printLog calls in examples/RTOS/RTOS.ino, but these are in example code and don't affect the core implementation
  • Two commented-out LOG calls in KeyboardAdapter.h don't follow the F() pattern but they're inactive

The implementation is largely consistent, with only example code needing updates for full uniformity.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining printLog calls and verify LOG macro usage

# Test 1: Check for any remaining printLog calls
echo "Checking for remaining printLog calls..."
rg "printLog\(" 

# Test 2: Verify LOG macro definition and implementation
echo "Checking LOG macro definition..."
rg "^#define\s+LOG\b" "src/"

# Test 3: Check LOG usage pattern across codebase
echo "Checking LOG usage patterns..."
rg "LOG\(F\(" 

Length of output: 3309

src/ItemInputCharset.h (3)

60-60: LGTM! Logging placement is appropriate.

The LOG call is well-positioned after character selection and provides useful debugging information.


67-67: LGTM! Logging is consistent with UP command implementation.

The LOG call maintains consistency in debug information across navigation commands.


Line range hint 60-143: Verify the LOG macro implementation in utils.h.

The logging changes look consistent. Let's verify the LOG macro implementation to ensure it handles the parameter types correctly.

✅ Verification successful

Let me gather more information about the logging implementation to make a thorough verification.


LOG macro implementation is correctly handling the parameter types

The verification reveals that the LOG macro implementation in utils.h is well-designed and properly handles all the logging cases in ItemInputCharset.h:

  1. The macro is conditionally compiled (#ifdef DEBUG) with a no-op fallback
  2. It supports two function overloads:
    • Single parameter: log(const __FlashStringHelper* command)
    • Two parameters: log(const __FlashStringHelper* command, T value) where T is templated
  3. All LOG calls in ItemInputCharset.h follow these patterns:
    • LOG(F("ItemInputCharset::up"), charset[charsetPosition])
    • LOG(F("ItemInputCharset::abortCharEdit"))

The logging implementation correctly handles both string literals (using Arduino's F macro for flash storage) and various value types through template parameter.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the LOG macro definition and its usage pattern
rg -p "LOG\(" "src/utils/utils.h"

Length of output: 100


Script:

#!/bin/bash
# Let's check the log function implementation and its context
rg -p "void log" "src/utils/utils.h" -B 5 -A 10

# Also check if there are any other logging-related functions or macros
rg -p "log|LOG" "src/utils/utils.h"

# Let's also check how LOG is being used in the codebase for parameter patterns
rg "LOG\(.*\)" "src/"

Length of output: 3775

src/input/KeyboardAdapter.h (1)

201-204: Verify the intended behavior for End/Home keys.

The code logs End and Home key events but doesn't process them. Is this intentional, or should these keys trigger specific menu actions?

✅ Verification successful

Let me try a different search strategy to verify the End/Home key handling.

The first command will help us find any files containing End/Home references, while the second command will show us the context around these specific CSI sequences ('H' for Home, 'F' for End) to understand their implementation better.


Let me search for more context around the keyboard handling implementation to understand if there's any existing pattern for handling navigation keys.

This will help us understand the overall key handling patterns and whether navigation keys like Home/End should have specific actions implemented.


Let me check the menu interface to understand what navigation actions are supported.

This will help us understand what actions are available in the menu system and whether Home/End navigation should be implemented.


Let me try one final search to find the menu-related definitions.

This will help us understand the menu navigation system and available actions to determine if Home/End keys should be implemented.


Based on the comprehensive code analysis, I can now generate the final response.

End/Home key events are intentionally logged but not processed

The codebase shows a clear pattern for handling navigation keys:

  • Arrow keys (UP/DOWN/LEFT/RIGHT) are processed and trigger menu navigation actions
  • ENTER/BACK/BACKSPACE have specific menu behaviors
  • Other special keys like PgUp, PgDn, Insert are also only logged without actions

The End/Home key logging is consistent with the codebase's pattern of logging unimplemented keys for debugging purposes, similar to PgUp and PgDn. This appears to be intentional as these keys are not part of the core navigation scheme used by the menu system.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any existing End/Home key handling in the codebase
rg -l "End|Home" --type cpp --type hpp

Length of output: 68


Script:

#!/bin/bash
# Search for End/Home key handling in C/C++ files with broader extension patterns
rg -l "End|Home" -g "*.{h,hpp,c,cpp}"

# Also search for specific CSI handling patterns that might include End/Home
rg -A 5 "case 'H':|case 'F':" -g "*.{h,hpp,c,cpp}"

Length of output: 1184


Script:

#!/bin/bash
# Look for other key handling patterns in KeyboardAdapter
rg -B 5 -A 10 "case.*:" src/input/KeyboardAdapter.h

# Check CharacterDisplayRenderer for any navigation-related functionality
cat src/renderer/CharacterDisplayRenderer.cpp

Length of output: 7487


Script:

#!/bin/bash
# Check menu interface for supported actions
rg -B 2 -A 2 "enum.*Action" -g "*.{h,hpp,c,cpp}"

# Look for menu process method implementation
ast-grep --pattern 'process($$$) {
  $$$
}'

Length of output: 96


Script:

#!/bin/bash
# Search for menu-related files and their content
fd -e h -e cpp "Menu" --exec cat {}

# Also look specifically for action definitions
rg "UP|DOWN|LEFT|RIGHT|ENTER|BACK" -B 2 -A 2 -g "*.{h,hpp,c,cpp}"

Length of output: 46763

src/ItemInput.h (4)

103-103: LGTM! Logging placement is appropriate.

The LOG call is correctly placed after the value update.


181-181: LGTM! Logging placement is appropriate.

The LOG call is correctly placed after all state changes are complete.


211-211: LGTM! Logging placement is appropriate in navigation methods.

The LOG calls are correctly placed after all state changes in both left and right navigation methods.

Also applies to: 232-232


253-253: Verify the remove helper function implementation.

The logging is correctly placed, but let's verify the implementation of the remove helper function used for string manipulation.

#!/bin/bash
# Look for the remove function implementation
ast-grep --pattern 'void remove(char* $str, $_pos, $_len) { $$$  }'

src/utils/utils.h Show resolved Hide resolved
src/utils/utils.h Outdated Show resolved Hide resolved
src/ItemToggle.h Show resolved Hide resolved
src/MenuScreen.cpp Outdated Show resolved Hide resolved
src/MenuScreen.cpp Outdated Show resolved Hide resolved
src/ItemRangeBase.h Show resolved Hide resolved
src/ItemInputCharset.h Show resolved Hide resolved
src/ItemInputCharset.h Show resolved Hide resolved
src/input/KeyboardAdapter.h Show resolved Hide resolved
src/input/KeyboardAdapter.h Show resolved Hide resolved
In KeyboardAdapter, ItemCommand, ItemInput, ItemInputCharset, ItemList, and ItemRangeBase classes.

- Removed redundant printLog calls for various actions.
- Updated logging to use the LOG macro for consistency.
@forntoh forntoh force-pushed the enhancement/improved-logging branch from 991cc30 to 92dec87 Compare October 23, 2024 23:43
Updated logging function calls in toggleRelay functions to use LOG macro instead of printLog for consistency and clarity.
coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 24, 2024
Adjusted logging messages in the MenuScreen class to provide more specific information when navigating up and down within the menu.
- Changed log messages in multiple test files from using single colon to double colon for MenuScreen actions.
Repository owner deleted a comment from coderabbitai bot Oct 24, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 15

🧹 Outside diff range comments (2)
src/ItemSubMenu.h (1)

Line range hint 1-4: Add missing include for LOG macro.

The LOG macro is used in the code but its header file is not included. This could lead to compilation errors.

Add the required include at the top of the file:

#ifndef ItemSubMenu_H
#define ItemSubMenu_H
#include "LcdMenu.h"
#include "MenuItem.h"
+#include "utils/utils.h"  // For LOG macro
src/MenuScreen.cpp (1)

Line range hint 108-112: Consider adding logging to reset() method.

For consistency with other navigation methods, consider adding logging to track when the screen is reset.

 void MenuScreen::reset(MenuRenderer* renderer) {
     cursor = 0;
     view = 0;
     draw(renderer);
+    LOG("MenuScreen::reset", cursor);
 }
🧰 Tools
🪛 cppcheck

[style] 108-108: The function 'reset' is never used.

(unusedFunction)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 991cc30 and ce85443.

📒 Files selected for processing (20)
  • examples/RTOS/RTOS.ino (1 hunks)
  • src/ItemCommand.h (1 hunks)
  • src/ItemInput.h (8 hunks)
  • src/ItemInputCharset.h (3 hunks)
  • src/ItemList.h (4 hunks)
  • src/ItemRangeBase.h (4 hunks)
  • src/ItemSubMenu.h (1 hunks)
  • src/ItemToggle.h (1 hunks)
  • src/LcdMenu.cpp (1 hunks)
  • src/MenuScreen.cpp (2 hunks)
  • src/input/KeyboardAdapter.h (2 hunks)
  • src/renderer/MenuRenderer.h (1 hunks)
  • src/utils/utils.h (1 hunks)
  • test/Basic.test.yml (1 hunks)
  • test/Callbacks.test.yml (1 hunks)
  • test/IntFloatValues.test.yml (3 hunks)
  • test/ItemBack.test.yml (1 hunks)
  • test/List.test.yml (2 hunks)
  • test/MenuTimeout.test.yml (1 hunks)
  • test/SubMenu.test.yml (1 hunks)
🧰 Additional context used
📓 Learnings (3)
src/ItemInputCharset.h (1)
Learnt from: forntoh
PR: forntoh/LcdMenu#250
File: src/ItemInputCharset.h:143-144
Timestamp: 2024-10-23T23:46:58.953Z
Learning: In `src/ItemInputCharset.h`, within the `commitCharEdit` method, do not include the full updated value in the log messages.
src/ItemList.h (1)
Learnt from: forntoh
PR: forntoh/LcdMenu#250
File: src/ItemList.h:141-141
Timestamp: 2024-10-24T00:16:02.760Z
Learning: In the `ItemList` class (`src/ItemList.h`), for the `selectNext` method, keep the `LOG` call outside the `if` block to support tests that assert that the value doesn't change when an action is performed. This ensures that logging occurs even when the selection does not change.
src/input/KeyboardAdapter.h (1)
Learnt from: forntoh
PR: forntoh/LcdMenu#250
File: src/input/KeyboardAdapter.h:210-220
Timestamp: 2024-10-23T23:45:14.170Z
Learning: You prefer to keep the logging messages for special keys in their current form and do not wish to add more context to them.
🔇 Additional comments (33)
test/Basic.test.yml (3)

7-7: LGTM! Downward navigation test sequence is properly updated.

The test correctly validates the menu navigation bounds by:

  1. Testing navigation from position 0 to 4
  2. Verifying that position stays at 4 when trying to go beyond

Also applies to: 9-9, 11-11, 13-13, 15-15


17-17: LGTM! Upward navigation test sequence is properly updated.

The test correctly validates the menu navigation bounds by:

  1. Testing navigation from position 4 back to 0
  2. Verifying that position stays at 0 when trying to go beyond

Also applies to: 19-19, 21-21, 23-23, 25-25


7-25: Verify test coverage for edge cases.

While the basic navigation flow is well tested, consider adding test cases for:

  1. Rapid button presses
  2. Long button press behavior (if supported)
  3. Concurrent up/down button presses (if possible in hardware)

Let's check if these scenarios are covered in other test files:

src/ItemSubMenu.h (1)

35-35: LGTM! Logging change looks good.

The update from printLog to LOG macro is consistent with the PR objectives to standardize logging across the codebase. The logging provides good context by including both the class/method name and the menu item text.

Let's verify the consistency of LOG macro usage across other menu item classes:

✅ Verification successful

Let me try a different approach to locate the files and verify the logging consistency.


LOG macro usage is consistent across all Item classes

The verification shows that the LOG macro is being used consistently across all Item classes with the proper format of LOG("ClassName::methodName", value). There are no remaining printLog calls in any of the Item files, confirming that the logging standardization has been completed successfully.

The logging in ItemSubMenu::changeScreen follows the same pattern as other Item classes:

  • All LOG calls include the class and method name as context
  • All LOG calls include a relevant value being logged
  • No legacy printLog calls remain
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistent LOG macro usage across menu item classes
# Expected: All Item* classes should use the LOG macro with similar format

# Search for LOG usage in Item* classes
rg "LOG\(" "src/Item.*"

# Also check for any remaining printLog calls that might have been missed
rg "printLog" "src/Item.*"

Length of output: 154


Script:

#!/bin/bash
# First, let's find all Item* files in the repository
fd "Item.*" --type f

# Then use the found files to check LOG and printLog usage
echo "=== Checking LOG macro usage ==="
fd "Item.*" --type f --exec rg "LOG\(" {}

echo "=== Checking printLog usage ==="
fd "Item.*" --type f --exec rg "printLog" {}

Length of output: 1773

test/List.test.yml (1)

7-7: LGTM! Log format updates are consistent.

The changes to double colon format align with the new logging mechanism update.

Also applies to: 19-19

test/SubMenu.test.yml (2)

10-26: LGTM! Consistent logging format update.

The logging format changes from single to double colon are applied consistently across all menu navigation steps, maintaining a uniform logging pattern.


30-30: LGTM! Logging format consistency maintained across different contexts.

The updated logging format is consistently applied in different navigation contexts (after sub-menu entry and back navigation), ensuring uniform logging throughout the test flow.

Also applies to: 38-38

src/utils/utils.h (1)

42-44: Verify the DEBUG flag behavior.

The current implementation disables logging when DEBUG is defined, which seems counterintuitive. Typically, debug logging is enabled when DEBUG is defined. Please verify if this is the intended behavior.

Also applies to: 56-57

test/IntFloatValues.test.yml (1)

7-7: LGTM! Log format standardization looks consistent.

The update to use double colons (::) in MenuScreen log messages aligns with the broader standardization effort across test files.

Also applies to: 23-23, 41-41

src/ItemCommand.h (2)

Line range hint 1-63: LGTM! Clean implementation with good documentation.

The class is well-documented with clear purpose and usage instructions. The logging change maintains the same semantic meaning while adopting the new logging mechanism.


60-60: Verify LOG macro inclusion

The code uses the LOG macro but I don't see its inclusion. Please ensure the header file that defines the LOG macro is properly included.

Let's verify the LOG macro definition:

✅ Verification successful

Let me try a different approach to search for the LOG macro and its inclusion without specifying file extensions.


Let's check the utils.h file since it appears in the LOG macro usage results and is a common location for utility macros.


LOG macro is properly included through inheritance chain

The verification shows that:

  1. The LOG macro is defined in src/utils/utils.h
  2. ItemCommand.h includes MenuItem.h
  3. MenuItem.h includes utils/utils.h

Therefore, the LOG macro is properly available in ItemCommand.h through the include chain, and no additional includes are needed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for LOG macro definition
echo "Searching for LOG macro definition..."
rg -l 'LOG\s*\(' --type hpp --type h

# Search for potential includes of the logging header
echo "Searching for logging-related includes..."
rg -l '#include.*log' --type hpp --type h

Length of output: 316


Script:

#!/bin/bash
# Search for LOG macro definition with broader pattern
echo "Searching for LOG macro definition..."
rg -l 'LOG\s*\(' 

# Search for potential includes of the logging header
echo "Searching for logging-related includes..."
rg -l '#include.*log'

# Look at the content of ItemCommand.h to see its includes
echo "Checking ItemCommand.h includes..."
rg -p '^#include' src/ItemCommand.h

Length of output: 620


Script:

#!/bin/bash
# Check utils.h content for LOG macro definition
echo "Checking utils.h for LOG macro..."
rg -p 'LOG' src/utils/utils.h

# Check if utils.h is included in the chain
echo "Checking if utils.h is included in MenuItem.h..."
rg -p '^#include' src/MenuItem.h

Length of output: 481

src/ItemToggle.h (1)

Line range hint 1-7: Verify LOG macro dependency.

The file includes utils/utils.h which should contain the LOG macro definition. Let's verify this to ensure proper compilation.

✅ Verification successful

Based on the shell script results, I can now generate the final response since I have sufficient information about the LOG macro definition and its usage across the codebase.

LOG macro is properly included and consistently used

The verification shows that:

  • The LOG macro is correctly defined in utils/utils.h with proper fallback
  • The macro implementation uses variadic arguments and Flash memory optimization
  • The usage pattern in ItemToggle.h matches the consistent format used across the codebase:
    • Component name followed by action
    • Additional context values when relevant
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify LOG macro definition and its usage pattern across files

# Check if LOG macro is defined in utils.h
rg -A 3 "LOG\s*\(" "src/utils/utils.h"

# Check consistency of LOG usage pattern across files
rg -A 1 "LOG\s*\([^)]+\)" "src/"

Length of output: 4837

src/MenuScreen.cpp (5)

71-71: Refer to previous review comment about adding context to back navigation logging.


78-78: LGTM! Logging implementation is correct and informative.

The log message includes the viewShift parameter which provides valuable context for debugging horizontal scrolling.


85-85: LGTM! Logging implementation is correct and informative.

The log message includes the viewShift parameter which provides valuable context for debugging horizontal scrolling.


97-97: LGTM! Logging implementation is correct and informative.

The log message includes the cursor position which provides valuable context for debugging vertical navigation.


105-105: LGTM! Logging implementation is correct and informative.

The log message includes the cursor position which provides valuable context for debugging vertical navigation.

src/renderer/MenuRenderer.h (1)

116-116: LGTM: Logging mechanism update is appropriate.

The change from printLog to LOG aligns with the PR's objective of standardizing the logging mechanism across the codebase.

src/ItemList.h (4)

102-102: LGTM: Appropriate logging placement after edit mode exit.

The LOG placement captures the final state after exiting edit mode and executing the callback.


118-118: LGTM: Appropriate logging placement after edit mode entry.

The LOG placement provides symmetry with the exit logging and captures the state when entering edit mode.


132-132: LGTM: Logging placement aligns with test requirements.

Keeping the LOG call outside the if block is intentional to support test assertions for both change and no-change scenarios.


141-141: LGTM: Logging placement consistent with selectPrevious.

The LOG placement follows the same pattern as selectPrevious(), supporting test assertions as intended.

src/ItemRangeBase.h (4)

66-66: LGTM: Logging change maintains functionality.

The conversion to the new LOG macro preserves the necessary debug information while aligning with the new logging standard.


78-78: LGTM: Consistent with increment() logging pattern.

The logging change maintains symmetry with the increment() method and follows the same logging standard.


125-125: LGTM: Edit mode transition logging updated correctly.

The conversion to the LOG macro maintains the necessary state transition information while standardizing the logging mechanism.

Also applies to: 151-151


66-66: Verify thread safety of the new LOG macro.

While the logging changes are consistent, it's important to ensure the new LOG macro is thread-safe, especially for concurrent menu operations.

Also applies to: 78-78, 125-125, 151-151

src/ItemInputCharset.h (3)

60-60: LGTM! Logging change looks good.

The LOG macro is correctly implemented to track character selection during upward navigation.


67-67: LGTM! Logging change looks good.

The LOG macro is correctly implemented to track character selection during downward navigation.


127-127: LGTM! Logging changes respect the established guidelines.

The LOG macro implementation in both methods maintains the desired level of logging detail, following the established guideline to keep log messages concise.

Also applies to: 143-143

src/input/KeyboardAdapter.h (2)

139-139: LGTM - Respecting previous feedback on logging.

Based on previous feedback, keeping these log statements commented out aligns with the author's preferences.

Also applies to: 143-143


201-201: LGTM - Clean logging implementation.

The logging implementation is consistent and matches the established style. The state machine properly resets after processing C2 terminal symbols, maintaining clean state transitions.

Let's verify the state machine transitions:

Also applies to: 204-204, 210-210, 216-216, 219-219

✅ Verification successful

Let me gather more information about the state machine implementation to ensure completeness of the verification.


Let me check one more aspect to verify the complete state machine implementation, particularly focusing on the CSI handling logic.


State machine implementation verified - All transitions and resets are properly handled

The verification confirms that:

  • The state machine properly handles CSI sequences with appropriate buffer management
  • Reset calls are correctly placed after:
    • Unsupported C1 commands
    • C2 terminal symbols
    • Unknown code sets
  • Buffer management is bounded (CSI_BUFFER_SIZE = 5) with proper cursor tracking
  • All special key logging (End, Home, Insert, PgUp, PgDn) is consistently implemented within the state machine
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify state machine implementation completeness
# Look for any potential missing state transitions or inconsistent reset calls

# Test 1: Check for all CodeSet enum values being handled
ast-grep --pattern 'enum class CodeSet {
  $$$
}'

# Test 2: Verify reset() calls in all necessary switch cases
rg -A 2 'reset\(\);.*// Reset after' src/input/KeyboardAdapter.h

Length of output: 483


Script:

#!/bin/bash
# Let's analyze the state machine implementation more thoroughly

# Check the CodeSet enum definition and its usage in switch statements
ast-grep --pattern 'switch ($codeSet) {
  $$$
}'

# Look for the csiBuffer and related state management
rg -B 2 -A 5 'csiBuffer\[csiBufferCursor\]' src/input/KeyboardAdapter.h

# Check for any other reset() calls we might have missed
rg 'reset\(\)' src/input/KeyboardAdapter.h

Length of output: 720


Script:

#!/bin/bash
# Analyze CSI handling and state transitions

# Look for CSI-related constants and their usage
rg -B 2 -A 2 'CSI' src/input/KeyboardAdapter.h

# Check the handleReceived method implementation
ast-grep --pattern 'void handleReceived(uint8_t command) {
  $$$
}'

# Look for buffer size constants and bounds checking
rg 'csiBufferCursor' -B 2 -A 2 src/input/KeyboardAdapter.h

Length of output: 1966

src/ItemInput.h (2)

103-103: LGTM! Logging implementation is well-placed.

The logging is correctly positioned after the value change and within the conditional block, ensuring we only log actual changes.


103-103: Verify the LOG macro implementation.

The logging changes consistently use the new LOG macro. Let's verify its implementation to ensure proper functionality.

Also applies to: 181-181, 194-194, 211-211, 232-232, 253-253, 290-290, 300-300

✅ Verification successful

Let me check the LOG macro implementation in more detail by examining its definition in utils.h.


I can now generate the final response based on the verification results.

LOG macro implementation is properly defined and consistently used

The LOG macro is well-implemented in src/utils/utils.h with:

  • A preprocessor macro that forwards arguments to the log function
  • Two inline function overloads for logging:
    • Single argument version for command-only logs
    • Template version for command-with-value logs
  • Proper use of Flash memory storage with F() macro
  • All usage patterns across the codebase follow the correct format

The implementation aligns well with the logging changes in the PR, providing both debug-enabled and no-op versions of the macro.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the LOG macro definition and its implementation
echo "Searching for LOG macro definition..."
rg -l "^#define\s+LOG\b" --type cpp

echo "Checking LOG macro usage patterns..."
rg "LOG\s*\(" --type cpp -A 1

Length of output: 4794


Script:

#!/bin/bash
# Get the complete LOG macro implementation from utils.h
echo "LOG macro implementation:"
rg -A 5 "^#define\s+LOG\b" src/utils/utils.h

echo -e "\nChecking if there are any log function implementations:"
rg "^.*void\s+log\s*\(" src/utils/utils.h -A 3

Length of output: 782

test/MenuTimeout.test.yml Show resolved Hide resolved
test/Callbacks.test.yml Show resolved Hide resolved
test/ItemBack.test.yml Show resolved Hide resolved
src/LcdMenu.cpp Outdated Show resolved Hide resolved
test/List.test.yml Show resolved Hide resolved
examples/RTOS/RTOS.ino Outdated Show resolved Hide resolved
src/ItemToggle.h Outdated Show resolved Hide resolved
src/renderer/MenuRenderer.h Outdated Show resolved Hide resolved
src/ItemInput.h Outdated Show resolved Hide resolved
src/ItemInput.h Outdated Show resolved Hide resolved
Updated wait-serial messages to match expected format.
@forntoh forntoh force-pushed the enhancement/improved-logging branch from ce85443 to b4f958d Compare October 24, 2024 05:30
Repository owner deleted a comment from github-actions bot Oct 24, 2024
Repository owner deleted a comment from github-actions bot Oct 24, 2024
Copy link
Contributor

Memory usage change @ b4f958d

Board flash % RAM for global variables %
STMicroelectronics:stm32:GenF1 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:avr:uno 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkr1000 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
esp32:esp32:esp32 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
esp8266:esp8266:huzzah N/A N/A N/A N/A
Click for full report table
Board examples/Basic
flash
% examples/Basic
RAM for global variables
% examples/ButtonAdapter
flash
% examples/ButtonAdapter
RAM for global variables
% examples/Callbacks
flash
% examples/Callbacks
RAM for global variables
% examples/InputRotary
flash
% examples/InputRotary
RAM for global variables
% examples/IntFloatValues
flash
% examples/IntFloatValues
RAM for global variables
% examples/KeyboardAdapter
flash
% examples/KeyboardAdapter
RAM for global variables
% examples/List
flash
% examples/List
RAM for global variables
% examples/SimpleRotary
flash
% examples/SimpleRotary
RAM for global variables
% examples/SSD1803A_I2C
flash
% examples/SSD1803A_I2C
RAM for global variables
% examples/RTOS
flash
% examples/RTOS
RAM for global variables
%
STMicroelectronics:stm32:GenF1 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:avr:uno 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:samd:mkr1000 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
esp32:esp32:esp32 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
esp8266:esp8266:huzzah N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
Click for full report CSV
Board,examples/Basic<br>flash,%,examples/Basic<br>RAM for global variables,%,examples/ButtonAdapter<br>flash,%,examples/ButtonAdapter<br>RAM for global variables,%,examples/Callbacks<br>flash,%,examples/Callbacks<br>RAM for global variables,%,examples/InputRotary<br>flash,%,examples/InputRotary<br>RAM for global variables,%,examples/IntFloatValues<br>flash,%,examples/IntFloatValues<br>RAM for global variables,%,examples/KeyboardAdapter<br>flash,%,examples/KeyboardAdapter<br>RAM for global variables,%,examples/List<br>flash,%,examples/List<br>RAM for global variables,%,examples/SimpleRotary<br>flash,%,examples/SimpleRotary<br>RAM for global variables,%,examples/SSD1803A_I2C<br>flash,%,examples/SSD1803A_I2C<br>RAM for global variables,%,examples/RTOS<br>flash,%,examples/RTOS<br>RAM for global variables,%
STMicroelectronics:stm32:GenF1,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:avr:uno,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:samd:mkr1000,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,
esp32:esp32:esp32,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
esp8266:esp8266:huzzah,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,,,,

@forntoh forntoh added the enhancement Improve readability/performance/maintainability label Oct 24, 2024
@forntoh forntoh marked this pull request as ready for review October 24, 2024 07:27
@forntoh forntoh merged commit aba1e49 into master Oct 24, 2024
21 checks passed
@forntoh forntoh deleted the enhancement/improved-logging branch October 24, 2024 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve readability/performance/maintainability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant