elimu-ai / webapp

🖥 Web application for hosting Android applications and educational content
https://hin.elimu.ai
MIT License
30 stars 55 forks source link

Reduce log level within loops #1726

Closed jo-elimu closed 1 month ago

jo-elimu commented 1 month ago
          **Optimize logging within loops.**

Logging within loops can be expensive. Consider reducing the log level or aggregating logs.

- logger.info("word.getText(): " + word.getText());
+ logger.debug("word.getText(): " + word.getText());
Committable suggestion > :bangbang: **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion List words = wordDao.readAll(); logger.info("words.size(): " + words.size()); for (Word word : words) { logger.debug("word.getText(): " + word.getText()); for (LetterSound letterSound : word.getLetterSounds()) { letterSoundFrequencyMap.put(letterSound.getId(), letterSoundFrequencyMap.getOrDefault(letterSound.getId(), 0) + word.getUsageCount()); } } `````

_Originally posted by @coderabbitai[bot] in https://github.com/elimu-ai/webapp/pull/1725#discussion_r1676883575_


The webapp in production is configured to only output logs with threshold level INFO or higher: https://github.com/elimu-ai/webapp/blob/main/src/main/resources/log4j2_PROD.xml#L3

alexander-kuruvilla commented 1 month ago

Hi, can I take this up?